Top |
gpointer | (*NcmMemoryPoolAlloc) () |
NcmMemoryPool * | ncm_memory_pool_new () |
void | ncm_memory_pool_free () |
guint | ncm_memory_pool_empty () |
void | ncm_memory_pool_set_min_size () |
void | ncm_memory_pool_add () |
gpointer | ncm_memory_pool_get () |
void | ncm_memory_pool_return () |
NcmMemoryPool is a generic memory pool, it alloc memory using a user defined function and save it for future use, the memory must be returned to the pool using ncm_memory_pool_return. These functions are thread safe.
NcmMemoryPool * ncm_memory_pool_new (NcmMemoryPoolAlloc mp_alloc
,gpointer userdata
,GDestroyNotify mp_free
);
This function prepare a memory pool which allocate memory using mp_alloc and save it for future use, the memory must be returned to the pool using ncm_memory_pool_return. These functions are thread safe.
[skip]
mp_alloc |
a NcmMemoryPoolAlloc, function used to alloc memory. |
|
userdata |
userdata pointer for |
|
mp_free |
function used to free memory alloced by mp_alloc. |
void ncm_memory_pool_free (NcmMemoryPool *mp
,gboolean free_slices
);
This function free the memory pool and also the slices if free_slices == TRUE and the pool was built with a free function
mp |
a NcmMemoryPool, memory pool to be freed |
|
free_slices |
if true and the pool was built with a free function, free the slices |
guint ncm_memory_pool_empty (NcmMemoryPool *mp
,gboolean free_slices
);
This function free all the slices in the pool and also the slices if free_slices == TRUE and the pool was built with a free function
mp |
a NcmMemoryPool, memory pool to be emptied |
|
free_slices |
if true and the pool was built with a free function, free the slices |
void ncm_memory_pool_set_min_size (NcmMemoryPool *mp
,gsize n
);
if n grater than number of slices then allocate new slices until n == slices.
void ncm_memory_pool_add (NcmMemoryPool *mp
,gpointer p
);
Adds an already allocated pointer p
to the pool. It will be freed with
NcmMemoryPool->free during the pool destruction.
gpointer
ncm_memory_pool_get (NcmMemoryPool *mp
);
Search in the pool for a non used slice and return the first finded. If none allocate a new one add to the pool and return it.
struct NcmMemoryPoolSlice { gpointer p; gboolean in_use; NcmMemoryPool *mp; };
Pointer to the actual slice. |
||
Boolean determining if the slice is in use. |
||
NcmMemoryPool * |
A back pointer to the pool. |