Synopsis

PDX_MSGT mda_AddMemory(long option, void *ent, void *ptr, void *new_ptr)

Purpose

Adds allocated memory to an entity.

Description

The memory referenced by ptr will be associated with ent. The pointer ptr must be previously set by calling one of the mda memory allocation functions with NULL for the ent parameter. After calling this function, the memory will be swapped to and from memory when ent is swapped. If the memory was allocated with mda_MallocArray, mda_CallocArray, or mda_ReallocArray, the MDA_ARRAY option must be specified.

After this function returns, the memory will be associated with ent just as if ent had been passed when the memory was originally allocated. Thus, the following call: .nf T_ENT *ent;

mda_Malloc ( MDA_NOOPT, ent, sizeof(int) * 4, &ent->ints ); .fi is identical to: .nf T_ENT *ent; int *array;

mda_Malloc ( MDA_NOOPT, NULL, sizeof(int) * 4, &array ); mda_AddMemory ( MDA_NOOPT, ent, array, &ent->ints ); .fi Note that the new_ptr argument is the address of the pointer to the allocated memory. This must be a field within the entity referenced by ent.

Input

option

MDA_ARRAY

The memory referenced by ptr was allocated with one of mda_MallocArray, mda_CallocArray, or mda_ReallocArray.

ent

The entity to associate @ptr with

ptr

Address of memory previously allocated with an mda memory allocation function

new_ptr

Address within ent where memory is to be referenced from

Output

new_ptr

The field within the entity updated to point to the previously allocated memory

Return

MDA error code