Flux Reference Manual |
---|
flux-mem-chunk —
#define FLUX_MEM_CHUNK (mem_chunk) struct MemChunkFreeNode; struct FluxMemChunk; FluxMemChunk* flux_mem_chunk_new (guint atomcount, guint atomsize); void flux_mem_chunk_init (FluxMemChunk *mem_chunk, guint atomcount, guint atomsize); void flux_mem_chunk_finalize (FluxObject *mem_chunk); gpointer flux_mem_chunk_alloc (FluxMemChunk *m); gpointer flux_mem_chunk_alloc0 (FluxMemChunk *m); void flux_mem_chunk_free (FluxMemChunk *m, gpointer mem); void flux_mem_chunk_clean (FluxMemChunk *m); void flux_mem_chunk_reset (FluxMemChunk *m);
struct FluxMemChunk { FluxObject object; guint blocksize; /* Number of atoms in a block */ guint atomsize; /* Size of each atom */ GPtrArray *blocks; /* Blocks of raw memory */ MemChunkFreeNode *free; };
FluxMemChunk* flux_mem_chunk_new (guint atomcount, guint atomsize);
Create a new memchunk header. Memchunks are an efficient way to allocate and deallocate identical sized blocks of memory quickly, and space efficiently.
flux_mem_chunks are effectively the same as gmemchunks, only faster (much), and they use less memory overhead for housekeeping.
atomcount : | The number of atoms stored in a single malloc'd block of memory. |
atomsize : | The size of each allocation. |
Returns : | The new header. |
void flux_mem_chunk_init (FluxMemChunk *mem_chunk, guint atomcount, guint atomsize);
mem_chunk : | |
atomcount : | |
atomsize : |
gpointer flux_mem_chunk_alloc (FluxMemChunk *m);
Allocate a new atom size block of memory from a memchunk.
m : | |
Returns : |
void flux_mem_chunk_free (FluxMemChunk *m, gpointer mem);
Free a single atom back to the free pool of atoms in the given memchunk.
m : | |
mem : | Address of atom to free. |
void flux_mem_chunk_clean (FluxMemChunk *m);
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).
m : |
void flux_mem_chunk_reset (FluxMemChunk *m);
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.
m : |
<< flux-object | flux-data-cache >> |