heap: properly check the alignment in memory of a heap_buf_t pointer.
[bertos.git] / bertos / struct / heap.c
index 27f8032567ae8945d70e6482a31a2c0afd90db85..33c6de2acadca599ee7057a4dc6710df16a4fba8 100644 (file)
@@ -56,7 +56,7 @@ void heap_init(struct Heap* h, void* memory, size_t size)
        memset(memory, FREE_FILL_CODE, size);
        #endif
 
-       ASSERT2((((uintptr_t)memory % sizeof(heap_buf_t)) == 0),
+       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 */