X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fstruct%2Fheap.c;h=27f8032567ae8945d70e6482a31a2c0afd90db85;hb=24eabd04c475344982213f43dd2f9cabec05d3ea;hp=dc8ceaab8e03df4cc2916ecaba936027277153d8;hpb=b90e284547eab472e3d9e478a058304bdd6b2da7;p=bertos.git diff --git a/bertos/struct/heap.c b/bertos/struct/heap.c index dc8ceaab..27f80325 100644 --- a/bertos/struct/heap.c +++ b/bertos/struct/heap.c @@ -38,28 +38,26 @@ #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((((uintptr_t)memory % sizeof(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;