Top |
Functions
CamelMemPool * | camel_mempool_new () |
gpointer | camel_mempool_alloc () |
gchar * | camel_mempool_strdup () |
void | camel_mempool_flush () |
void | camel_mempool_destroy () |
Functions
camel_mempool_new ()
CamelMemPool * camel_mempool_new (gint blocksize
,gint threshold
,CamelMemPoolFlags flags
);
Create a new mempool header. Mempools can be used to efficiently allocate data which can then be freed as a whole.
Mempools can also be used to efficiently allocate arbitrarily aligned data (such as strings) without incurring the space overhead of aligning each allocation (which is not required for strings).
However, each allocation cannot be freed individually, only all or nothing.
Parameters
blocksize |
The base blocksize to use for all system alocations. |
|
threshold |
If the allocation exceeds the threshold, then it is allocated separately and stored in a separate list. |
|
flags |
Alignment options: CAMEL_MEMPOOL_ALIGN_STRUCT uses native struct alignment, CAMEL_MEMPOOL_ALIGN_WORD aligns to 16 bits (2 bytes), and CAMEL_MEMPOOL_ALIGN_BYTE aligns to the nearest byte. The default is to align to native structures. |
Since: 2.32
camel_mempool_alloc ()
gpointer camel_mempool_alloc (CamelMemPool *pool
,gint size
);
Allocate a new data block in the mempool. Size will be rounded up to the mempool's alignment restrictions before being used.
Since: 2.32
camel_mempool_strdup ()
gchar * camel_mempool_strdup (CamelMemPool *pool
,const gchar *str
);
Since: 2.32
camel_mempool_flush ()
void camel_mempool_flush (CamelMemPool *pool
,gint freeall
);
Flush used memory and mark allocated blocks as free.
If freeall
is TRUE
, then all allocated blocks are free'd
as well. Otherwise only blocks above the threshold are
actually freed, and the others are simply marked as empty.
Since: 2.32
camel_mempool_destroy ()
void
camel_mempool_destroy (CamelMemPool *pool
);
Free all memory associated with a mempool.
Since: 2.32