NAME
OTC_Heap -
Memory allocator.
SYNOPSIS
#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;
};
CLASS TYPE
Concrete
DESCRIPTION
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.
CONSTRUCTION
OTC_Heap(char* theMemory, size_t theSize);
Creates a memory heap using 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.
ALLOCATION/DEALLOCATION
void* allocate(size_t theSize);
Allocates and returns a piece of memory of
theSize. If there is insufficient memory,
0 is returned.
void release(void* theMemory);
Returns theMemory back to the heap. If
the memory was not originally allocated
from this heap, the result is undefined.
QUERY
static size_t minimum();
Returns the minimum size permitted, for
the array of memory the heap is to use.
DEBUG
void dump(ostream& outs) const;
Dumps information about the heap structure
to outs. Useful for debugging purposes
only.
LIBRARY
OTC
AUTHOR(S)
Graham Dumpleton
COPYRIGHT
Copyright 1993 OTC LIMITED
Copyright 1994 DUMPLETON SOFTWARE CONSULTING PTY LIMITED