X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fstruct%2Fheap.c;h=33c6de2acadca599ee7057a4dc6710df16a4fba8;hb=eb43b8e3d3107c865cbb4c47b12e375ea29ea089;hp=2375c1f140ebcd2267090f4285edd91c295fdf56;hpb=2d8af52f104df99da4e64987081c7d4d08ac278a;p=bertos.git diff --git a/bertos/struct/heap.c b/bertos/struct/heap.c index 2375c1f1..33c6de2a 100644 --- a/bertos/struct/heap.c +++ b/bertos/struct/heap.c @@ -32,34 +32,32 @@ * * \brief Heap subsystem (public interface). * - * \version $Id: heap.c 1532 2008-08-04 07:21:26Z bernie $ + * \version $Id$ * \author Bernie Innocenti */ #include "heap.h" -#include // IS_POW2() -#include // ASSERT() - -#include // memset() - -/* NOTE: struct size must be a 2's power! */ -typedef struct _MemChunk -{ - struct _MemChunk *next; - size_t size; -} MemChunk; - -STATIC_ASSERT(IS_POW2(sizeof(MemChunk))); +#include // ASSERT() +#include // memset() #define FREE_FILL_CODE 0xDEAD #define ALLOC_FILL_CODE 0xBEEF + +/* + * This function prototype is deprecated, will change in: + * void heap_init(struct Heap* h, heap_buf_t* memory, size_t size) + * in the nex BeRTOS release. + */ void heap_init(struct Heap* h, void* memory, size_t size) { -#ifdef _DEBUG + #ifdef _DEBUG memset(memory, FREE_FILL_CODE, size); -#endif + #endif + + ASSERT2(((size_t)memory % alignof(heap_buf_t)) == 0, + "memory buffer is unaligned, please use the HEAP_DEFINE_BUF() macro to declare heap buffers!\n"); /* Initialize heap with a single big chunk */ h->FreeList = (MemChunk *)memory;