cr8r_sla Struct Reference

Slab allocator. More...

#include <sla.h>

Data Fields

void ** slabs
 Array of pointers to "slabs" (elements buffers). More...
 
void * first_elem
 Pointer to first unallocated element. More...
 
uint64_t slabs_len
 Number of slabs.
 
uint64_t slab_cap
 Capacity of last slab.
 
uint64_t elem_size
 Size of a single element.
 

Detailed Description

Slab allocator.

Aggregates small, fixed size allocations to decrease dynamic memory requests. Maintains an array of "slabs", buffers of many fixed size elements. The unallocated elements are linked together so that unallocated elements can be found and returned and allocated elements can be deallocated trivially.

This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

Definition at line 22 of file sla.h.

Field Documentation

◆ slabs

void** cr8r_sla::slabs

Array of pointers to "slabs" (elements buffers).

Each buffer is twice the size of the last. New buffers are allocated only whem all elements on all buffers have been allocated. Creating new buffers in this way allows the backing storage to be increased without needing to move existing allocated elements.

Definition at line 26 of file sla.h.

◆ first_elem

void* cr8r_sla::first_elem

Pointer to first unallocated element.

Internally, each unallocated element contains a pointer to the next unallocated element at the beginning of its memory, hence slab allocators can only be created if the element size is >= sizeof(void*)

Definition at line 29 of file sla.h.


The documentation for this struct was generated from the following file: