Symisc Systems

Libcox C/C++ API Reference - Array Type Processing

Star Follow @symisc


int libcox_array_insert(libcox_value *pArray,libcox_value *pValue);

int libcox_array_insert_strkey_elem(libcox_value *pArray,const char*zKey,libcox_value *pValue);

Populate a Libcox array.


These routines are used to populate a libcox array object. The given libcox_value (first argument) must be of type array obtained by a prior successful call to libcox_context_new_array(). Otherwise these routines return immediately with an error code.

The second argument to libcox_array_insert() is a libcox_value obtained by a prior successful call to libcox_context_new_scalar(), libcox_context_new_array() or passed as parameter to the foreign command.

The second argument to libcox_array_insert_strkey_elem() is a pointer to a nul terminated string holding the entry key to be inserted which can be extracted later using libcox_array_fetch_by_key.

The inserted record could be extracted later using libcox_array_fetch() or libcox_array_next_elem(). Note that if you want a null entry value, simply pass NULL.

Note: These routines make its own copy of the given value pair so it's safe to use the same libcox_value for other insertions.

Note: These routines are not thread-safe.



libcox_value to perform the insertion on which must be of type array.


A pointer to a nul terminated string holding the entry key.


libcox_value to be inserted.

Return value

LIBCOX_OK is returned on success. Any other return value typically (LIBCOX_CORRUPT) indicates failure.

See also

libcox_array_next_elem, libcox_array_walk, libcox_array_fetch.