Memory, Tfree, Tmalloc – Argox PA-20 Programming Guide User Manual

Page 102: Totalheapsize, Usedheapsize

Advertising
background image

PT-20 Programming Guide

100

Memory

Tfree

Purpose: Use the Tfree to release an allocated storage block to the pool of free

memory.

Syntax: void Tfree(void *mem_address);

Example call: Tfree(buffer);

Includes:

#include “SDK.h”

Description: 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.

Returns: None

Tmalloc

Purpose: Use Tmalloc to allocate memory for an array of a given number of bytes,

not exceeding 256KB.

Syntax: void* Tmalloc(U32 num_bytes);

Example call: buffer = (char *)Tmalloc(100*sizeof(char));

Includes:

#include “SDK.h”

Description: 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.

Returns: 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.

Comments: Note that when using Tmolloc to allocate storage for a specific data type,

you should cast the returned void pointer to that type.

TotalHeapSize

Purpose: Checking the total heap size.

Syntax: int TotalHeapSize(void);

Example call: totalsize = TotalHeapSize();

Includes:

#include “SDK.h ”

Description: The TotalHeapSize function can get the total heap size.

Returns: The total heap size in units of Kbytes.

UsedHeapSize

Advertising