
PT-20 Programming Guide
Memory
Use the Tfree to release an allocated storage block to the pool of free
memory.
void Tfree(void *mem_address);
The Tfree function returns to the pool of free memory a blockof memory
that was allocated earlier by Tmalloc. The address of the block is specified
by the argument mem_address, which is a pointer to the starting byte of the
block. A NULL pointer argument is ignored by Tfree.
Use Tmalloc to allocate memory for an array of a given number of bytes,
not exceeding 256KB.
void* Tmalloc(U32 num_bytes);
buffer = (char *)Tmalloc(100*sizeof(char));
The Tmalloc function allocates the number of bytes requested in the
argument num_bytes by calling internal Turbo C heap management
routines. The Tmalloc function will work properly for all memory models.
The Tmalloc function returns a pointer that is the starting address of the
memory allocated. The allocated memory is properly aligned (the address
of the first byte meets the requirements for storing any type of C variable). If
the memory allocation is unsuccessful because of insufficient space or bad
values of the arguments, a NULL is returned.
Note that when using Tmolloc to allocate storage for a specific data type,
you should cast the returned void pointer to that type.
Checking the total heap size.
totalsize = TotalHeapSize();
The TotalHeapSize function can get the total heap size.
The total heap size in units of Kbytes.
Commenti su questo manuale