astStore

Store data in dynamically allocated memory

Description:

This function stores data in dynamically allocated memory, allocating the memory (or adjusting the size of previously allocated memory) to match the amount of data to be stored.

Synopsis

void astStore( void ptr, const void data, size_t size )

Parameters:

ptr
Pointer to previously allocated memory (or NULL if none has yet been allocated).
data
Pointer to the start of the data to be stored. This may be given as NULL if there are no data, in which case it will be ignored and this function behaves like astRealloc, preserving the existing memory contents.
size
The total size of the data to be stored and/or the size of memory to be allocated. This may be zero, in which case the data parameter is ignored, any previously-allocated memory is freed and a NULL pointer is returned.

Returned Value

astStore()
If the data were stored successfully, a pointer to the start of the possibly new memory region is returned (this may be the same as the original pointer). If size was given as zero, a NULL pointer is returned.

Notes: