18.2.222. PMIx_Argv_append_unique_nosize

PMIx_Argv_append_unique_nosize — Append a copy of a string to a NULL-terminated argv-style array only if it is not already present.

18.2.222.1. SYNOPSIS

#include <pmix.h>

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

18.2.222.1.1. Python Syntax

No Python equivalent

18.2.222.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.222.3. INPUT PARAMETERS

  • arg: The string to append. The routine stores a private copy only if the string is not already present; the caller retains ownership of arg.

18.2.222.4. DESCRIPTION

Append the string arg to the array referenced by *argv only if no existing entry compares equal to it.

The routine scans the current entries and compares each against arg using strcmp. If an exact match is found, the array is left unchanged and the call succeeds. Otherwise, or when *argv is NULL, the string is appended exactly as by PMIx_Argv_append_nosize(3) — the array is reallocated, a private copy of arg is stored, and a new terminating NULL is written. *argv is updated to the resulting array pointer.

Comparison is by full string equality; matching is case-sensitive.

18.2.222.5. RETURN VALUE

Returns one of:

  • PMIX_SUCCESS The string was appended, or was already present so no change was needed.

  • PMIX_ERR_OUT_OF_RESOURCE Memory could not be allocated while appending a new entry.

18.2.222.6. EXAMPLES

char **argv = NULL;

PMIx_Argv_append_unique_nosize(&argv, "x");
PMIx_Argv_append_unique_nosize(&argv, "x");   /* no-op, still one entry */
/* argv == { "x", NULL } */

PMIx_Argv_free(argv);