Symisc Systems

Libcox C/C++ API Reference - On Demand Object Allocation

Star Follow @symisc


libcox_value * libcox_context_new_scalar(libcox_context *pCtx);

libcox_value * libcox_context_new_array(libcox_context *pCtx);

void libcox_context_release_value(libcox_context *pCtx,libcox_value *pValue);

Allocate libcox object values on demand


These routine allocate libcox_value on demand, they are used mostly by foreign commands which works with arrays.

libcox_context_new_array() allocate a new libcox_value of type array. The array can be populated later using libcox_array_insert().

libcox_context_release_value() destroy a libcox_value obtained by a prior successful call to libcox_context_new_scalar() or libcox_context_new_array().

libcox_context_new_scalar() allocate a new scalar libcox_value which is set to the null type by default. Use the following interfaces to populate the object with the desired value:


libcox_context_new_scalar() and libcox_context_new_array() takes as their first argument a pointer to a libcox_context which mean that they are designed to be invoked only from a foreign command.

Note that calling libcox_context_release_value() is not necessary since the libcox core will automatically destroy any allocated libcox_value as soon the foreign command have finished its execution.

Tip: if you want to return the allocated libcox_value inside your foreign command, use libcox_result_value().



Foreign command call context.

Return value

libcox_context_new_scalar(), libcox_context_new_array() return a pointer to a freshly allocated libcox_value on success. Otherwise NULL is returned on failure (i.e: Out of memory).

See also

Obtaining Libcox Object Values, Libcox Object Values Type, Populating Object Values, Setting the Result of a Foreign Command.