Symisc UnQLite

An Embeddable NoSQL Database Engine



UnQLite C/C++ API Reference - Call Context Memory Management Interfaces.

Syntax


void * unqlite_context_alloc_chunk(unqlite_context *pCtx,unsigned int nByte,int ZeroChunk,int AutoRelease);

void * unqlite_context_realloc_chunk(unqlite_context *pCtx,void *pChunk,unsigned int nByte);

void unqlite_context_free_chunk(unqlite_context *pCtx,void *pChunk);


Memory Allocation Routines


Description


As their names suggests these interfaces allocate, re-allocate and free memory using the UnQLite memory backend subsystem. These interfaces accepts as their first parameter a pointer to a unqlite_context which mean that they are designed to be invoked only from a foreign function.


The unqlite_context_alloc_chunk() routine returns a pointer to a block of memory at least nByte bytes in length, where nByte is the second parameter. 

The last parameter unqlite_context_alloc_chunk() takes is a Boolean flag when set to TRUE (any value different from zero), then the allocated chunk is automatically released upon the foreign function have finished its execution. That is, there is no need to manually call unqlite_context_free_chunk().


The unqlite_context_realloc_chunk() interface attempts to resize a prior memory allocation to be at least nByte bytes, where nByte is the third parameter. The memory allocation to be resized is the second parameter. If the second parameter to unqlite_context_realloc_chunk() is a NULL pointer then its behavior is identical to calling unqlite_context_alloc_chunk(nByte) where nByte is the third parameter to unqlite_context_realloc_chunk().


Calling unqlite_context_free_chunk() with a pointer previously returned by unqlite_context_alloc_chunk() or unqlite_context_realloc_chunk() releases that memory so that it might be reused. Passing a NULL pointer to unqlite_context_free_chunk() is harmless. Note that after being freed, memory should neither be read nor written otherwise the result is undefined


Parameters


pCtx

Foreign function Call Context.


Return value


A pointer to a freshly allocated/re-allocated chunk is returned on success. NULL is returned on failure (Out-of-memory).


See also


Installing Foreign Functions.



Symisc Systems
Copyright © Symisc Systems