#include <OTC/memory/heap.hh> class OTC_Heap {
public:
static os_typespec* get_os_typespec();
OTC_Heap(char* theMemory, size_t theSize);
void* allocate(size_t theSize);
void release(void* theMemory);
static size_t minimum();
void dump(ostream& outs) const;
};
OTC_Heap
provides heap style memory management, for a
chunk of memory. The class uses the boundary tag method of
allocation. The implementation is based on ideas from the book
C++, A Guide for C Programmers by Sharam Hekmatpour.
OTC_Heap(char* theMemory, size_t theSize);
theMemory
,
where theSize
is the size of the
memory. theSize
must be greater than or
equal to OTC_Heap::minimum()
. If
theSize
is less, 0
will always be
returned by allocate()
. theMemory
is
not deleted if this class is ever deleted,
ie., it is your responsibility to delete
theMemory
if required.
void* allocate(size_t theSize);
theSize
. If there is insufficient memory,
0
is returned.
void release(void* theMemory);
theMemory
back to the heap. If
the memory was not originally allocated
from this heap, the result is undefined.
static size_t minimum();
void dump(ostream& outs) const;
outs
. Useful for debugging purposes
only.