| HeapAllocPtr | Function (ROM Call 0xA2)

alloc.h

void *HeapAllocPtr (unsigned long Size);

Allocates memory at the high end of the heap and returns a pointer to the allocated block.

HeapAllocPtr performs HeapAllocHigh, but instead of the handle, it returns a pointer to the allocated block (NULL in a case of error). It also gives a necessary information to the heap manager which is needed later for deallocating the memory using HeapFreePtr command. This routine is principally equivalent to ANSI C malloc function, so it is aliased here also as malloc.
Note: If somebody is interested in it, the handle of the allocated block is stored two bytes below the address returned by HeapAllocPtr.

Uses: HeapAllocHigh, NeedStack
Used by: calloc, HeapAllocPtrThrow, realloc, LoadDLL, fopen, scanf, vscanf, atexit