Class Freelist

Nested Relationships

Nested Types

Class Documentation

class Freelist

Public Functions

inline explicit Freelist(size_t quantum)

Construct a new Freelist object.

Parameters:

quantum – The number of bytes that are allocated in one allocation

inline Freelist()
inline void set_quantum(size_t new_quantum)

Sets the quantum.

Parameters:

new_quantum – The new quantum

inline void add_region(Region *region)

Adds a region to the allocator.

Parameters:

region – The region to add

inline Result<uintptr_t, Error> alloc()

Allocates quantum bytes.

Returns:

The allocation on success, the error on failure.

inline void free(uintptr_t mem)

Frees quantum bytes from address.

Parameters:

mem – The address to free

struct Region

A chunk of memory.

Public Members

size_t size

Size of the region.

Region *next

Pointer to the next free region.