Is there a way to create a heap at a specific memory location (separate from the system heap) that can be used for dynamic memory allocation, but makes use of the dynamic memory allocator built into the C library.
I'm looking for something functionally equivalent to this:
UserHeap heap(startAddress, size);
void* allocatedMemory1 = heap.Allocate(100); //Allocate 100 bytes.
void* allocatedMemory2 = heap.Allocate(200); //Allocate 200 bytes.
/* ... Do seomthing useful with the memory ... */
heap.Free(allocatedMemory1);
heap.Free(allocatedMemory2);
This uheap.h seems to have what I'm looking for, but this doesn't seem to exist in newlib. I'm wondering if GCC or newlib might have something. If not I think I may end up porting ptmalloc. However, its my understanding that this code is already in the C library and I'd hate to waste the memory reproducing it.
I'm using Sourcery Codebench Lite (GCC) with newlib (C library).
donate(char *p, int size)that let you donate some memory tomalloc's pool. It was useful (especially in those 64k address space days, that is) if you had a bunch of static data structures that were needed only during initialization, and you wanted to reuse their memory after you were done with them.