18.2.137. PMIx_Data_array_construct
PMIx_Data_array_construct — Initialize a caller-provided
pmix_data_array_t(5) and allocate its element
storage.
18.2.137.1. SYNOPSIS
#include <pmix.h>
void PMIx_Data_array_construct(pmix_data_array_t *p,
size_t num, pmix_data_type_t type);
18.2.137.1.1. Python Syntax
No Python equivalent
18.2.137.2. INPUT PARAMETERS
p: Pointer to the pmix_data_array_t(5) structure to be initialized. The storage for the structure itself must already exist — it is supplied by the caller.num: Number of elements to allocate in the backing array.type: The pmix_data_type_t(5) of the elements.
18.2.137.3. DESCRIPTION
Initialize a pmix_data_array_t and, when
num is greater than zero, allocate and initialize a backing array of
num elements of the given type. The type and size fields are
set accordingly and the array field is set to point at the newly allocated
element storage.
The allocation is type-aware: for complex PMIx types (for example PMIX_INFO,
PMIX_PROC, PMIX_VALUE, PMIX_APP, PMIX_ENVAR, and many others)
the elements are created and constructed using the appropriate per-type
routine; for scalar types (for example PMIX_INT, PMIX_SIZE,
PMIX_BOOL, PMIX_STRING) an array of the corresponding C type is
allocated and zeroed. If num is zero, no element storage is allocated and
array is set to NULL. If type is not recognized, array is set
to NULL and size is reset to zero.
18.2.137.4. RETURN VALUE
PMIx_Data_array_construct returns no value (void).
18.2.137.5. NOTES
Because PMIx_Data_array_construct operates on caller-provided structure
storage but allocates the element array, it must be paired with
PMIx_Data_array_destruct(3), which
releases the element storage (and any per-element payload) without freeing the
pmix_data_array_t structure itself. To also allocate the structure, use
PMIx_Data_array_create(3). To initialize
the fields without allocating element storage, use PMIx_Data_array_init(3).
18.2.137.6. EXAMPLES
Construct an array of four pmix_info_t(5) elements:
pmix_data_array_t darray;
PMIx_Data_array_construct(&darray, 4, PMIX_INFO);
/* ... populate darray.array[0..3] ... */
PMIx_Data_array_destruct(&darray);