18.2.221. PMIx_Argv_append_nosize

PMIx_Argv_append_nosize — Append a copy of a string to the end of a NULL-terminated argv-style array.

18.2.221.1. SYNOPSIS

#include <pmix.h>

pmix_status_t PMIx_Argv_append_nosize(char ***argv, const char *arg);

18.2.221.1.1. Python Syntax

No Python equivalent

18.2.221.2. INPUT/OUTPUT PARAMETERS

  • argv: Address of a pointer to a NULL-terminated argv-style array. On input, *argv may be NULL (in which case a new array is created) or point to an existing array. On output, *argv is updated to point at the (possibly reallocated) array.

18.2.221.3. INPUT PARAMETERS

  • arg: The string to append. The routine stores a private copy; the caller retains ownership of arg.

18.2.221.4. DESCRIPTION

Append the string arg to the end of the array referenced by *argv.

If *argv is NULL, a new two-element array is allocated: element zero holds the copied string and element one is the terminating NULL. If *argv already points to an array, the array is reallocated one entry larger, a copy of arg (made with strdup) is stored in the newly opened slot, and a fresh terminating NULL is written after it. In both cases *argv is updated to the resulting array pointer, which the caller must use in place of any prior value because reallocation may move the array.

Only the string arg is duplicated; the routine takes ownership of the copy it makes, and that copy is released when the array is later passed to PMIx_Argv_free(3).

18.2.221.5. RETURN VALUE

Returns one of:

  • PMIX_SUCCESS The string was appended successfully.

  • PMIX_ERR_OUT_OF_RESOURCE Memory could not be allocated for the array or the copied string.

18.2.221.6. NOTES

The _nosize suffix indicates that, unlike the internal pmix_argv_append routine, this function does not accept or update a separate element-count argument. Use PMIx_Argv_count(3) when the current number of entries is needed.

18.2.221.7. EXAMPLES

char **argv = NULL;

PMIx_Argv_append_nosize(&argv, "first");
PMIx_Argv_append_nosize(&argv, "second");
/* argv == { "first", "second", NULL } */

PMIx_Argv_free(argv);