X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fmware%2Fheap.h;fp=bertos%2Fmware%2Fheap.h;h=0a987b134b92d6b42592ec26311440e45f21f729;hb=e5174304054e26cd8f3cd1f9980871c20c07fc46;hp=0524dbcfa3b7a5abc8ada90f6906c6f084734bbe;hpb=bad932366898b7153f2cba75c06cec2d86f35fe1;p=bertos.git diff --git a/bertos/mware/heap.h b/bertos/mware/heap.h index 0524dbcf..0a987b13 100644 --- a/bertos/mware/heap.h +++ b/bertos/mware/heap.h @@ -1,92 +1 @@ -/** - * \file - * - * - * \brief Heap subsystem (public interface). - * - * \todo Heap memory could be defined as an array of MemChunk, and used - * in this form also within the implementation. This would probably remove - * memory alignment problems, and also some aliasing issues. - * - * \version $Id$ - * - * \author Bernie Innocenti - * - */ - -#ifndef MWARE_HEAP_H -#define MWARE_HEAP_H - -#include "cfg/cfg_heap.h" -#include - -struct _MemChunk; - -/// A heap -struct Heap -{ - struct _MemChunk *FreeList; ///< Head of the free list -}; - - -/// Initialize \a heap within the buffer pointed by \a memory which is of \a size bytes -void heap_init(struct Heap* heap, void* memory, size_t size); - -/// Allocate a chunk of memory of \a size bytes from the heap -void *heap_allocmem(struct Heap* heap, size_t size); - -/// Free a chunk of memory of \a size bytes from the heap -void heap_freemem(struct Heap* heap, void *mem, size_t size); - - -#define HNEW(heap, type) \ - (type*)heap_allocmem(heap, sizeof(type)) - -#define HNEWVEC(heap, type, nelem) \ - (type*)heap_allocmem(heap, sizeof(type) * (nelem)) - -#define HDELETE(heap, type, mem) \ - heap_freemem(heap, mem, sizeof(type)) - -#define HDELETEVEC(heap, type, nelem, mem) \ - heap_freemem(heap, mem, sizeof(type) * (nelem)) - - -#if CONFIG_HEAP_MALLOC - -void *heap_malloc(struct Heap* heap, size_t size); -void *heap_calloc(struct Heap* heap, size_t size); -void heap_free(struct Heap* heap, void * mem); - -#endif - -#endif /* MWARE_HEAP_H */ +#include