gskmempool

gskmempool —

Synopsis




struct      GskMemPool;
struct      GskMemPoolFixed;
void        gsk_mem_pool_construct          (GskMemPool *pool);
gpointer    gsk_mem_pool_alloc              (GskMemPool *pool,
                                             gsize size);
gpointer    gsk_mem_pool_alloc0             (GskMemPool *pool,
                                             gsize size);
char*       gsk_mem_pool_strdup             (GskMemPool *pool,
                                             const char *str);
void        gsk_mem_pool_destruct           (GskMemPool *pool);
void        gsk_mem_pool_fixed_construct    (GskMemPoolFixed *pool,
                                             gsize size);
gpointer    gsk_mem_pool_fixed_alloc        (GskMemPoolFixed *pool);
gpointer    gsk_mem_pool_fixed_alloc0       (GskMemPoolFixed *pool);
void        gsk_mem_pool_fixed_free         (GskMemPoolFixed *pool,
                                             gpointer from_pool);
void        gsk_mem_pool_fixed_destruct     (GskMemPoolFixed *pool);

Description

Details

struct GskMemPool

struct GskMemPool {

};


struct GskMemPoolFixed

struct GskMemPoolFixed {

};


gsk_mem_pool_construct ()

void        gsk_mem_pool_construct          (GskMemPool *pool);

Initialize the members of a mem-pool. (The memory for the mem-pool structure itself must be provided: either as a part of another structure or on the stack.)

pool: the mem-pool to initialize.

gsk_mem_pool_alloc ()

gpointer    gsk_mem_pool_alloc              (GskMemPool *pool,
                                             gsize size);

Allocate memory from a pool, This function terminates the program if there is an out-of-memory condition.

pool: area to allocate memory from.
size: number of bytes to allocate.
Returns : the slab of memory allocated from the pool.

gsk_mem_pool_alloc0 ()

gpointer    gsk_mem_pool_alloc0             (GskMemPool *pool,
                                             gsize size);

Allocate memory from a pool, initializing it to 0. This function terminates the program if there is an out-of-memory condition.

pool: area to allocate memory from.
size: number of bytes to allocate.
Returns : the slab of memory allocated from the pool.

gsk_mem_pool_strdup ()

char*       gsk_mem_pool_strdup             (GskMemPool *pool,
                                             const char *str);

Allocated space from the mem-pool to store the given string (including its terminal NUL character) and copy the string onto that buffer.

If str is NULL, the NULL is returned.

pool: area to allocate memory from.
str: a string to duplicate, or NULL.
Returns : a copy of str, allocated from pool.

gsk_mem_pool_destruct ()

void        gsk_mem_pool_destruct           (GskMemPool *pool);

Destroy all chunk associated with the given mem-pool.

pool: the pool to destroy.

gsk_mem_pool_fixed_construct ()

void        gsk_mem_pool_fixed_construct    (GskMemPoolFixed *pool,
                                             gsize size);

Set up a fixed-size memory allocator for use.

pool: the fixed-size memory pool to construct.
size: size of the allocation to take from the mem-pool.

gsk_mem_pool_fixed_alloc ()

gpointer    gsk_mem_pool_fixed_alloc        (GskMemPoolFixed *pool);

Allocate a block of the Fixed-Pool's size.

pool: the pool to allocate a block from.
Returns : the allocated memory.

gsk_mem_pool_fixed_alloc0 ()

gpointer    gsk_mem_pool_fixed_alloc0       (GskMemPoolFixed *pool);

Allocate a block of the Fixed-Pool's size. Set its contents to 0.

pool: the pool to allocate a block from.
Returns : the allocated, zeroed memory.

gsk_mem_pool_fixed_free ()

void        gsk_mem_pool_fixed_free         (GskMemPoolFixed *pool,
                                             gpointer from_pool);

Recycle some of the pool's memory back to it.

pool: the pool to return memory to.
from_pool: the memory to return to this pool. It must have been allocated from this pool.

gsk_mem_pool_fixed_destruct ()

void        gsk_mem_pool_fixed_destruct     (GskMemPoolFixed *pool);

Free all memory associated with this pool.

pool: the pool to destroy.