Synopsis

PDX_MSGT mda_ReallocArray(long option, void *ent, void *old_ptr, size_t size, void *ptr, int ndims, ...)

Purpose

Dynamically reallocate a multi-dimensional array.

Description

Reallocates an array of any number of dimensions to be of a new size. Any of the dimensions can be increased or decreased in size and this function will copy the existing data appropriately. The number of dimensions and size specified must be the same as the array was originally allocated with. The block must have been allocated with mda_MallocArray, mda_CallocArray, or mda_ReallocArray. Blocks allocated with mda_Malloc, mda_Calloc, mda_Realloc, or mda_Strdup must be reallocated using mda_Realloc.

If the memory has been associated with an entity (i.e. either the ent argument was not NULL when the memory was originally allocated or mda_AddMemory has been called), then the entity which owns the memory must be passed in ent. If the memory has not been associated, ent must be specified as NULL.

Note that the ptr argument is the address of the pointer to the allocated memory. If ent is not NULL, this must be a field within the entity pointed to by ent. The variable at the address ptr must be declared as a pointer indirected by the number of dimensions in the array.

Input

option

MDA_NO_COPY

Don't copy the data from the existing memory to the realloc'ed memory. This option reduces the amount of overhead significantly. If not specified, the appropriate data from the original array will be copied into the new array

ent

The entity which owns the allocated memory

old_ptr

The existing pointer to be reallocated

size

The number of bytes in each array element

ptr

Address to store the allocated memory pointer at

ndims

The number of dimensions in the array @a ... The dimensions listed from left most to right most specified as MDA_COUNT values

Output

ptr

The allocated memory

Return

MDA error code