18.2.138. PMIx_Data_array_create

PMIx_Data_array_create — Allocate and initialize a pmix_data_array_t(5) together with its element storage.

18.2.138.1. SYNOPSIS

#include <pmix.h>

pmix_data_array_t* PMIx_Data_array_create(size_t n, pmix_data_type_t type);

18.2.138.1.1. Python Syntax

No Python equivalent

18.2.138.2. INPUT PARAMETERS

18.2.138.3. DESCRIPTION

Allocate a single pmix_data_array_t structure from the heap and construct it (via PMIx_Data_array_construct(3)) so that its backing element array holds n elements of the given type. Both the structure and its element storage are owned by the caller.

18.2.138.4. RETURN VALUE

Returns a pointer to the newly allocated and initialized pmix_data_array_t on success. Returns NULL if n is zero or if the allocation of the structure fails.

18.2.138.5. NOTES

PMIx_Data_array_create both allocates and constructs, so it must be paired with PMIx_Data_array_free(3), which destructs the elements and frees the structure. Do not pass a created array to PMIx_Data_array_destruct(3) alone, as that releases the element storage without freeing the pmix_data_array_t structure itself.

18.2.138.6. EXAMPLES

Create a data array of eight pmix_proc_t(5) elements:

pmix_data_array_t *darray;

darray = PMIx_Data_array_create(8, PMIX_PROC);
if (NULL == darray) {
    /* handle allocation failure */
}
/* ... populate darray->array ... */
PMIx_Data_array_free(darray);