+#ifndef MWARE_HEAP_H
+#define MWARE_HEAP_H
+
+#include <compiler.h>
+#include <config.h>
+
+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))