Next: Data structures, Previous: Library features, Up: Embedding API [Contents][Index]
The core library of Serveez is able to keep track of the memory an application or part of a program consumes, and also controls itself in the same manner. When you are using this memory allocator interface you can determine and afterwards remove memory leaks. This is a very important feature as servers are by nature long-lived programs.
The three allocator function pointers for malloc
, realloc
and free
make it possible to instruct Serveez to use different
kinds of memory, which might be necessary if you want the library to work
with shared memory arenas or any other underlying memory API.
Set the internal memory management functions to cus_malloc,
cus_realloc and cus_free, respectively.
The default internal values are malloc
, realloc
and free
.
Allocate size bytes of memory and return a pointer to this block.
Allocate size bytes of memory and return a pointer to this block. The memory is cleared (filled with zeros).
Change the size of a block of memory at ptr, previously
returned by svz_malloc
, to size bytes. If ptr
is NULL
, allocate a new block.
Free a block of memory at ptr, previously returned by
svz_malloc
or svz_realloc
. If ptr is
NULL
, do nothing.
Duplicate the given string src if it is not NULL
and has
non-zero length. Return the new string.
Write values to to[0]
and to[1]
representing the
number of currently allocated bytes and blocks, respectively.
If Serveez was not configured with ‘--enable-debug’,
the values are always 0.
Next: Data structures, Previous: Library features, Up: Embedding API [Contents][Index]