Veritable Lasagna
An Allocator & Data Structure Library for C.
Loading...
Searching...
No Matches
vl_fixed_pool.c File Reference
#include "vl_fixed_pool.h"
#include <malloc.h>
#include <memory.h>
+ Include dependency graph for vl_fixed_pool.c:

Functions

vl_fixed_pool_node * vl_PoolNodeNew (vl_fixedpool *pool)
 
void vlFixedPoolInit (vl_fixedpool *pool, vl_ularge_t elementSize)
 Initializes the specified fixed pool instance.
 
vl_fixedpool_idx vlFixedPoolTake (vl_fixedpool *pool)
 
void vlFixedPoolReturn (vl_fixedpool *pool, vl_fixedpool_idx idx)
 
void vlFixedPoolClear (vl_fixedpool *pool)
 
void vlFixedPoolFree (vl_fixedpool *pool)
 De-initializes the specified pool instance.
 
void vlFixedPoolReset (vl_fixedpool *pool)
 
void vlFixedPoolReserve (vl_fixedpool *pool, vl_dsidx_t numElements)
 Ensures space for n-many elements in the pool.
 
vl_fixedpoolvlFixedPoolClone (const vl_fixedpool *src, vl_fixedpool *dest)
 Clones the specified source fixed pool.
 
vl_fixedpoolvlFixedPoolNew (vl_ularge_t elementSize)
 Allocates and initializes a fixed pool instance.
 
void vlFixedPoolDelete (vl_fixedpool *pool)
 De-initializes and deletes the specified fixed pool. This will clear up all memory associated with members of the pool. This pool should have been initialized via vlFixedPoolNew.
 

Function Documentation

◆ vl_PoolNodeNew()

vl_fixed_pool_node * vl_PoolNodeNew ( vl_fixedpool * pool)
+ Here is the caller graph for this function:

◆ vlFixedPoolClear()

void vlFixedPoolClear ( vl_fixedpool * pool)

Clears the specified pool. This does not clear any buffers associated with the pool. Rather, this resets each underlying memory block's counter to 0, and resets the free stack.

Parameters
poolfixed pool pointer
Complexity O(n) linear.

◆ vlFixedPoolClone()

vl_fixedpool * vlFixedPoolClone ( const vl_fixedpool * src,
vl_fixedpool * dest )

Clones the specified source fixed pool.

Clones the entirety of the src pool to the dest pool.

The 'src' pool pointer must be non-null and initialized. The 'dest' pool pointer may be null, but if it is not null it must be initialized.

If the 'dest' pool pointer is null, a new pool is initialized via vlFixedPoolNew. Otherwise, its element size is set to the source's and the destination is reset via vlFixedPoolReset.

See also
vlFixedPoolNew
Parameters
srcpointer to pool to clone
destpointer to target pool, or NULL
Complexity O(n) linear.
Returns
dest, or pool initialized via vlFixedPoolNew
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vlFixedPoolDelete()

void vlFixedPoolDelete ( vl_fixedpool * pool)

De-initializes and deletes the specified fixed pool. This will clear up all memory associated with members of the pool. This pool should have been initialized via vlFixedPoolNew.

See also
vlFixedPoolNew
Parameters
poolpointer
Complexity O(1) constant.
+ Here is the call graph for this function:

◆ vlFixedPoolFree()

void vlFixedPoolFree ( vl_fixedpool * pool)

De-initializes the specified pool instance.

This will clear up all memory associated with members of the pool.

This pool should have been initialized via vlFixedPoolInit.

See also
vlFixedPoolInit
Parameters
poolpointer
Complexity O(1) constant.
+ Here is the caller graph for this function:

◆ vlFixedPoolInit()

void vlFixedPoolInit ( vl_fixedpool * pool,
vl_ularge_t elementSize )

Initializes the specified fixed pool instance.

This pool should be freed via vlFixedPoolFree.

See also
vlFixedPoolFree
Parameters
poolpointer
elementSizesize of each element, in bytes.
Complexity O(1) constant.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vlFixedPoolNew()

vl_fixedpool * vlFixedPoolNew ( vl_ularge_t elementSize)

Allocates and initializes a fixed pool instance.

This pool should later be deleted via vlFixedPoolDelete.

See also
vlFixedPoolDelete
Parameters
elementSizesize of each element, in bytes.
Complexity O(1) constant.
Returns
pointer to pool instance
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vlFixedPoolReserve()

void vlFixedPoolReserve ( vl_fixedpool * pool,
vl_dsidx_t n )

Ensures space for n-many elements in the pool.

This is accomplished by using the standard buffer resizing method for this library, which is doubling the size of the underlying storage until it is greater than a specified minimum size. A new node may be created twice the size of all created before it.

This function will only sometimes result in allocation of a new node.

Parameters
poolpointer
ntotal elements to reserve space for
+ Here is the call graph for this function:

◆ vlFixedPoolReset()

void vlFixedPoolReset ( vl_fixedpool * pool)

Resets the specified pool. This deletes all but the initial memory block. This leaves the pool in a "new" state, freeing memory in the process.

Parameters
pool
Complexity O(n) linear.
+ Here is the caller graph for this function:

◆ vlFixedPoolReturn()

void vlFixedPoolReturn ( vl_fixedpool * pool,
vl_fixedpool_idx idx )

Gives the specified index back to the fixed pool, allowing it to be re-used.

Parameters
poolpointer
idxelement index
Complexity O(1) constant.
+ Here is the caller graph for this function:

◆ vlFixedPoolTake()

vl_fixedpool_idx vlFixedPoolTake ( vl_fixedpool * pool)

Takes a new index from the fixed pool, which corresponds to a valid memory location within the pool.

Parameters
poolpointer
Complexity O(1) constant.
Returns
index of new pool item.
+ Here is the call graph for this function:
+ Here is the caller graph for this function: