An Embeddable Datastore Engine |
Tweet |
Follow @Vedis |
Vedis C/C++ API Reference - On Demand Object Allocation.
vedis_value * vedis_context_new_scalar(vedis_context *pCtx);
vedis_value * vedis_context_new_array(vedis_context *pCtx);
void vedis_context_release_value(vedis_context *pCtx,vedis_value *pValue);
Description
These routine allocate vedis_value on demand, they are used mostly by foreign commands which works with arrays.
vedis_context_new_array() allocate a new vedis_value of type array. The array can be populated later using vedis_array_insert().
vedis_context_release_value()
destroy a vedis_value
obtained by a prior successful call to vedis_context_new_scalar()
or vedis_context_new_array().
vedis_context_new_scalar()
allocate a new scalar vedis_value
which is set to the null type by default. Use the following
interfaces to populate the object
with the desired value:
vedis_context_new_scalar() and vedis_context_new_array() takes as their first argument a pointer to a vedis_context which mean that they are designed to be invoked only from a foreign command.
Note that calling vedis_context_release_value() is not necessary since the vedis core will automatically destroy any allocated vedis_value as soon the foreign command have finished its execution.
Tip: if you want to return the allocated vedis_value inside your foreign command, use vedis_result_value().
Parameters
pCtx |
Foreign command call context. |
Return value
vedis_context_new_scalar(), vedis_context_new_array() return a pointer to a freshly allocated vedis_value on success. Otherwise NULL is returned on failure (i.e: Out of memory).
Example
Compile this C file for a smart introduction to these interfaces.
See also
Populating Object Values, Setting the Result of a Foreign Command, Obtaining Vedis Object Values.