Memory Pool Interface

DESCRIPTION

SilcStack is a pre-allocated memory pool system which allows fast memory allocation for routines and applications that frequently allocate small amounts of memory. Other advantage of this system is that there are no memory leaks, as long as the stack is freed eventually. Since the stack is usually allocated only once this is not an issue.

SilcStack supports stack pushing and popping allowing to push the stack, allocate memory and then pop it to free the allocated memory. The freeing does not actually do any real memory freeing so it is optimized for performance. The memory alignment may also be specified by user for the stack. This allows the caller to use special alignment for memory allocations, if needed.

SilcStack is also a full featured memory pool which allows user to group together multiple stacks. Child stacks may be created from a parent stack without consuming the parent stack. When the child is freed, its memory is returned back to the parent and can be used again by other childs. It is also possible to create child stacks from another child stack.

A basic set of utility functions are provided for application that wish to use the SilcStack as their primary memory allocation source. The following functions (among many others) support SilcStack:

silc_smalloc, silc_smalloc, silc_scalloc, silc_srealloc, silc_smemdup, silc_sfree, silc_sstrdup, silc_buffer_salloc, silc_buffer_salloc_size, silc_buffer_srealloc, silc_buffer_srealloc_size, silc_buffer_scopy, silc_buffer_sclone, silc_buffer_sformat, silc_buffer_sformat_vp, silc_buffer_sstrformat, silc_buffer_senlarge, silc_dlist_sinit, silc_hash_table_alloc

The SilcStack is not thread-safe so that same context could be used for allocations from multiple threads. It is however safe to create and use child stacks in a different thread from the parent stack. Each thread should allocate their own SilcStack, however they may be child stacks.

TABLE OF CONTENTS