Subastra
Loading...
Searching...
No Matches
Static Public Member Functions | Data Fields
freelist_ledger_t Struct Reference

An object that implements malloc-like behaviour without specifying the exact internal object being managed. More...

#include <freelist.h>

Collaboration diagram for freelist_ledger_t:
Collaboration graph
[legend]

Static Public Member Functions

static void freelist_ledger_init (freelist_ledger_t *ledger, allocator_t allocator, u32 capacity)
 
static freelist_ledger_ptr_t freelist_ledger_reserve (freelist_ledger_t *ledger, u32 size)
 Reserves the next block from the ledger. Returns FREELIST_LEDGER_INVALID_BLOCK if the requested block does not fit.
 
static void freelist_ledger_release (freelist_ledger_t *ledger, freelist_ledger_ptr_t at)
 Returns the block back into the pool.
 
static void freelist_ledger_cleanup (freelist_ledger_t *ledger)
 

Data Fields

list_t _blocks
 The blocks that were reserved. Contrary to the name, this list stores the busy blocks, not the free ones.
 
u32 capacity
 The maximum amount of slots managed by the ledger. Errors out if reached.
 

Detailed Description

An object that implements malloc-like behaviour without specifying the exact internal object being managed.

Functionallity equivalent to a slab allocator without any actual memory control.

Member Function Documentation

◆ freelist_ledger_cleanup()

static void freelist_ledger_cleanup ( freelist_ledger_t ledger)
static

◆ freelist_ledger_init()

static void freelist_ledger_init ( freelist_ledger_t ledger,
allocator_t  allocator,
u32  capacity 
)
static

◆ freelist_ledger_release()

static void freelist_ledger_release ( freelist_ledger_t ledger,
freelist_ledger_ptr_t  at 
)
static

Returns the block back into the pool.

◆ freelist_ledger_reserve()

static freelist_ledger_ptr_t freelist_ledger_reserve ( freelist_ledger_t ledger,
u32  size 
)
static

Reserves the next block from the ledger. Returns FREELIST_LEDGER_INVALID_BLOCK if the requested block does not fit.

Field Documentation

◆ _blocks

list_t _blocks

The blocks that were reserved. Contrary to the name, this list stores the busy blocks, not the free ones.

◆ capacity

u32 capacity

The maximum amount of slots managed by the ledger. Errors out if reached.