X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fstruct%2Fheap.h;h=9846079af7a734e73a40752d1353c43ce4779789;hb=ed914dcd14bb340d61a8bc011ec0cd7a0312ed79;hp=d76678b2090757a4a2c05e05a2394121644254bf;hpb=32d1445272120a254d77ce8d1af1f527da7a2c17;p=bertos.git diff --git a/bertos/struct/heap.h b/bertos/struct/heap.h index d76678b2..9846079a 100644 --- a/bertos/struct/heap.h +++ b/bertos/struct/heap.h @@ -30,14 +30,20 @@ * Copyright 1999, 2000, 2001, 2008 Bernie Innocenti * --> * + * \defgroup heap Embedded optimized memory allocator + * \ingroup core + * \{ + * * \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 + * + * $WIZ$ module_name = "heap" + * $WIZ$ module_configuration = "bertos/cfg/cfg_heap.h" */ #ifndef STRUCT_HEAP_H @@ -71,8 +77,7 @@ typedef struct Heap * \param size Heap size in bytes. */ #define HEAP_DEFINE_BUF(name, size) \ - heap_buf_t name[((size) + sizeof(heap_buf_t) - 1) / sizeof(heap_buf_t)]; \ - STATIC_ASSERT(sizeof(name) % sizeof(heap_buf_t) == 0) + heap_buf_t name[((size) + sizeof(heap_buf_t) - 1) / sizeof(heap_buf_t)] /// 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); @@ -83,6 +88,7 @@ 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); +size_t heap_freeSpace(struct Heap *h); #define HNEW(heap, type) \ (type*)heap_allocmem(heap, sizeof(type)) @@ -99,12 +105,19 @@ void heap_freemem(struct Heap* heap, void *mem, size_t size); #if CONFIG_HEAP_MALLOC +/** + * \name Compatibility interface with C standard library + * \{ + */ 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 +/** \} */ //defgroup heap + int heap_testSetup(void); int heap_testRun(void); int heap_testTearDown(void);