# Synopsis

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

# Purpose

Dynamically allocate a multi-dimensional array.

# Description

An array of any number of dimensions is allocated. If ent is not NULL, the memory is associated with the specified entity and will be swapped to and from memory when that entity is swapped. If ent is NULL the memory can later be added to an entity using mda_AddMemory.

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 referenced by ent. The variable at the address ptr must be declared as a pointer indirected by the number of dimensions in the array. The allocated array is stored contiguously in memory, just as it would if the dimensions were fixed. An example of allocating a variable array is shown below.

DDF entry for entity:

.nf count u; count v; float uv_paths[u][v];

The call to mda_MallocArray would be:

mda_MallocArray (MDA_NOOPT, &entity, sizeof(float), &entity.uv_paths, 2, entity.u, entity.v); .fi

# Input

## option

### MDA_ZERO_DATA

This option is provided for backwards compatibility, mda_MallocArray will always initialize the allocated memory to 0.

## ent

The entity which owns the allocated memory or NULL

## 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