Reduct  v4.0.5-1-g4851deb
A functional and immutable language.
Loading...
Searching...
No Matches
Arena

Detailed Description

Data Structures

struct  reduct_arena_t
 Arena structure. More...
 
struct  reduct_arena_chunk_t
 Arena chunk descriptor. More...
 
struct  reduct_arena_local_t
 Per-thread arena-related state structure. More...
 

Macros

#define REDUCT_ARENA_MIN   1024
 The minimum size of an arena in bytes.
 
#define REDUCT_ARENA_GROWTH    2
 The factor by which we increase the minimum size until the needed capacity is reached./*#end#*‍/.
 
#define REDUCT_ARENA_CHUNK(_arena, _size, _data)   ((reduct_arena_chunk_t){(_arena), (_size), (_data)})
 Create an arena chunk descriptor.
 

Functions

REDUCT_API void reduct_arena_local_init (reduct_arena_local_t *local)
 Initialize a local arena state.
 
REDUCT_API void reduct_arena_local_deinit (reduct_arena_local_t *local)
 Deinitialize a local arena state.
 
REDUCT_API void reduct_arena_alloc (struct reduct *reduct, size_t size, reduct_arena_chunk_t *out)
 Allocate a chunk of memory from a arena.
 
REDUCT_API void reduct_arena_alloc_super (struct reduct *reduct, size_t size, reduct_arena_chunk_t *chunk, reduct_arena_chunk_t *out)
 Allocate a super chunk that starts with the specified chunk.
 

Macro Definition Documentation

◆ REDUCT_ARENA_MIN

#define REDUCT_ARENA_MIN   1024

The minimum size of an arena in bytes.

Definition at line 17 of file arena.h.

◆ REDUCT_ARENA_GROWTH

#define REDUCT_ARENA_GROWTH    2

The factor by which we increase the minimum size until the needed capacity is reached./*#end#*‍/.

Definition at line 19 of file arena.h.

◆ REDUCT_ARENA_CHUNK

#define REDUCT_ARENA_CHUNK (   _arena,
  _size,
  _data 
)    ((reduct_arena_chunk_t){(_arena), (_size), (_data)})

Create an arena chunk descriptor.

Parameters
arenaPointer to the arena the chunk belongs to.
sizeThe size of the chunk in bytes.
dataPointer to the chunk data.
Returns
An arena chunk descriptor.

Definition at line 53 of file arena.h.

Function Documentation

◆ reduct_arena_local_init()

REDUCT_API void reduct_arena_local_init ( reduct_arena_local_t local)

Initialize a local arena state.

Parameters
localPointer to the local arena state to initialize.

◆ reduct_arena_local_deinit()

REDUCT_API void reduct_arena_local_deinit ( reduct_arena_local_t local)

Deinitialize a local arena state.

Parameters
localPointer to the local arena state to deinitialize.

◆ reduct_arena_alloc()

REDUCT_API void reduct_arena_alloc ( struct reduct *  reduct,
size_t  size,
reduct_arena_chunk_t out 
)

Allocate a chunk of memory from a arena.

Parameters
reductPointer to the Reduct structure.
sizeThe size of the chunk to allocate in bytes.
outPointer to store the allocated chunk descriptor.

◆ reduct_arena_alloc_super()

REDUCT_API void reduct_arena_alloc_super ( struct reduct *  reduct,
size_t  size,
reduct_arena_chunk_t chunk,
reduct_arena_chunk_t out 
)

Allocate a super chunk that starts with the specified chunk.

If the chunk is at the end of its arena and there is enough capacity, it will extend the existing allocation.

Parameters
reductPointer to the Reduct structure.
sizeThe size of the super chunk to allocate in bytes.
chunkThe description of the chunk to extend from.
outPointer to store the allocated super chunk information.