![]() |
![]() |
![]() |
Camel Reference Manual | ![]() |
---|---|---|---|---|
Top | Description |
CamelMemPool; enum CamelMemPoolFlags; CamelMemPool * camel_mempool_new (,
gint blocksize,
gint thresholdCamelMemPoolFlags flags
);gpointer camel_mempool_alloc (CamelMemPool *pool
,);
gint sizegchar * camel_mempool_strdup (CamelMemPool *pool
,const
);gchar *strvoid camel_mempool_flush (CamelMemPool *pool
,);
gint freeallvoid camel_mempool_destroy (CamelMemPool *pool
);
typedef enum { CAMEL_MEMPOOL_ALIGN_STRUCT, CAMEL_MEMPOOL_ALIGN_WORD, CAMEL_MEMPOOL_ALIGN_BYTE, CAMEL_MEMPOOL_ALIGN_MASK = 0x3 } CamelMemPoolFlags;
Allocate to native structure alignment | |
Allocate to words - 16 bit alignment | |
Allocate to bytes - 8 bit alignment | |
Which bits determine the alignment information |
Since 2.32
CamelMemPool * camel_mempool_new (,
gint blocksize,
gint thresholdCamelMemPoolFlags 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.
|
The base blocksize to use for all system alocations. |
|
If the allocation exceeds the threshold, then it is allocated separately and stored in a separate list. |
|
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
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.
|
a CamelMemPool |
Since 2.32
gchar * camel_mempool_strdup (CamelMemPool *pool
,const
);gchar *str
|
a CamelMemPool |
Since 2.32
void camel_mempool_flush (CamelMemPool *pool
,);
gint freeall
Flush used memory and mark allocated blocks as free.
If freeall
is TRUE
|
a CamelMemPool |
|
free all system allocated blocks as well |
Since 2.32
void camel_mempool_destroy (CamelMemPool *pool
);
Free all memory associated with a mempool.
|
a CamelMemPool |
Since 2.32