18.2.229. PMIx_Argv_split_with_empty

PMIx_Argv_split_with_empty — Split a string on a delimiter into a NULL-terminated argv-style array, retaining empty tokens.

18.2.229.1. SYNOPSIS

#include <pmix.h>

char **PMIx_Argv_split_with_empty(const char *src_string, int delimiter);

18.2.229.1.1. Python Syntax

No Python equivalent

18.2.229.2. INPUT PARAMETERS

  • src_string: The string to tokenize. May be NULL or empty.

  • delimiter: The character on which to split, passed as an int.

18.2.229.3. DESCRIPTION

Break src_string into tokens separated by delimiter and return the tokens as a freshly allocated, NULL-terminated argv-style array. Each token is an independently allocated copy of the corresponding substring.

Unlike PMIx_Argv_split(3), zero-length tokens are preserved: each run of consecutive delimiters, and a leading delimiter, yields an empty-string ("") entry in the result, so the number of entries reflects the delimiter structure of the input. This routine is a thin wrapper over PMIx_Argv_split_inter(3) with include_empty = true.

The returned array and all of its strings are owned by the caller and must be released with PMIx_Argv_free(3).

18.2.229.4. RETURN VALUE

Returns a newly allocated NULL-terminated array of token strings, including empty-string entries for zero-length tokens. If src_string is NULL or empty, the returned pointer is NULL. NULL is also returned if an internal allocation fails.

18.2.229.5. EXAMPLES

char **argv = PMIx_Argv_split_with_empty("a::b", ':');
/* argv == { "a", "", "b", NULL } -- empty token retained */

PMIx_Argv_free(argv);