astGrow

Allocate memory for an adjustable array

Description:

This function allocates memory in which to store an array of data whose eventual size is unknown. It should be invoked whenever a new array size is determined and will appropriately increase the amount of memory allocated when necessary. In general, it will over-allocate in anticipation of future growth so that the amount of memory does not need adjusting on every invocation.

Synopsis

void astGrow( void ptr, int n, size_t size )

Parameters:

ptr
Pointer to previously allocated memory (or NULL if none has yet been allocated).
n
Number of array elements to be stored (may be zero).
size
The size of each array element.

Returned Value

astGrow()
If the memory was allocated successfully, a pointer to the start of the possibly new memory region is returned (this may be the same as the original pointer).

Notes: