// 2 constants to be declared in the definition part of your main unit:
const HEAP_START:word = 2000; // the address of the lowest ram place to be used by the MemManager as Heap
HEAP_SIZE:word = 1000; // the size of that heap in bytes
procedure MM_Init;
// Initializes the memory manager
procedure GetMem(var P: Word; WantedSize: word);
// Fetches memory from the memory heap.
// Returns a pointer (> 0) to the fetched memory (of "WantedSize" bytes) in P if success,
// otherwise 0 (no free blocks of memory are large enough...). This is not a fatal error,
// there is only not enough memory at the moment. The memory manager stays operational.
// P is a variable of any pointer type.
// "WantedSize" is an expression specifying the size in bytes of the dynamic variable to allocate.
// Access the newly allocated memory by dereferencing the pointer; that is, use P^.
procedure FreeMem(var P: word; ActualSize: word);
// FreeMem destroys the variable referenced by P and returns its memory to the heap.
// P is a variable of any pointer type previously assigned by the GetMem procedure.
// "ActualSize" specifies the size in bytes of the dynamic variable to dispose of,
// and should be the same as the one used to "GetMem".
// After calling FreeMem, the value of P is nil (0) (not assigned pointer).