camel-memchunk: Camel Reference Manual

## camel-memchunk camel-memchunk |

## Functions

CamelMemChunk * | camel_memchunk_new ()
gpointer | camel_memchunk_alloc ()
gpointer | camel_memchunk_alloc0 ()
void | camel_memchunk_free ()
void | camel_memchunk_empty ()
void | camel_memchunk_clean ()
void | camel_memchunk_destroy ()

## Types and Values

| CamelMemChunk

## Description

## Functions

### camel_memchunk_new ()

    CamelMemChunk *
    camel_memchunk_new (gint atomcount,
                        gint atomsize);

Create a new CamelMemChunk header. Memchunks are an efficient way to allocate and deallocate identical sized blocks of memory quickly, and space efficiently.

camel_memchunks are effectively the same as gmemchunks, only faster (much), and they use less memory overhead for housekeeping.

[skip]

#### Parameters

atomcount | the number of atoms stored in a single malloc'd block of memory |
atomsize | the size of each allocation |

#### Returns

a new CamelMemChunk

Since: 3.4

### camel_memchunk_alloc ()

    gpointer
    camel_memchunk_alloc (CamelMemChunk *memchunk);

Allocate a new atom size block of memory from an CamelMemChunk. Free the returned atom with `camel_memchunk_free()`.

[skip]

#### Parameters

memchunk | an CamelMemChunk |

#### Returns

an allocated block of memory.

[transfer full]

Since: 3.4

### camel_memchunk_alloc0 ()

    gpointer
    camel_memchunk_alloc0 (CamelMemChunk *memchunk);

Allocate a new atom size block of memory from an CamelMemChunk, and fill the memory with zeros. Free the returned atom with `camel_memchunk_free()`.

[skip]

#### Parameters

memchunk | an CamelMemChunk |

#### Returns

an allocated block of memory.

[transfer full]

Since: 3.4

### camel_memchunk_free ()

    void
    camel_memchunk_free (CamelMemChunk *memchunk,
                         gpointer mem);

Free a single atom back to the free pool of atoms in the given memchunk.

[skip]

#### Parameters

memchunk | an CamelMemChunk |
mem | address of atom to free |

Since: 3.4

### camel_memchunk_empty ()

    void
    camel_memchunk_empty (CamelMemChunk *memchunk);

Clean out the memchunk buffers. Marks all allocated memory as free blocks, but does not give it back to the system. Can be used if the memchunk is to be used repeatedly.

[skip]

#### Parameters

memchunk | an CamelMemChunk |

Since: 3.4

### camel_memchunk_clean ()

    void
    camel_memchunk_clean (CamelMemChunk *memchunk);

Scan all empty blocks and check for blocks which can be free'd back to the system.

This routine may take a while to run if there are many allocated memory blocks (if the total number of allocations is many times greater than atomcount).

[skip]

#### Parameters

memchunk | an CamelMemChunk |

Since: 3.4

### camel_memchunk_destroy ()

    void
    camel_memchunk_destroy (CamelMemChunk *memchunk);

Free the memchunk header, and all associated memory.

[skip]

#### Parameters

memchunk | an CamelMemChunk |

Since: 3.4

## Types and Values

### CamelMemChunk

    typedef struct _CamelMemChunk CamelMemChunk;

Since: 3.4