Loading...
Searching...
No Matches
cxx::Slab_static< Type, Slab_size, Max_free, Alloc > Class Template Reference
Small C++ Template Library

Merged slab allocator (allocators for objects of the same size are merged together). More...

`#include <slab_alloc>`

Inheritance diagram for cxx::Slab_static< Type, Slab_size, Max_free, Alloc >:
Collaboration diagram for cxx::Slab_static< Type, Slab_size, Max_free, Alloc >:

## Public Member Functions

Type * | alloc () noexcept
| Allocate an object of type Type.
Public Member Functions inherited from cxx::Base_slab_static< sizeof(Type), L4_PAGESIZE, 2, New_allocator >
void * | alloc () noexcept
| Allocate an object.
void | free (void *p) noexcept
| Free the given object (p).
unsigned | total_objects () const noexcept
| Get the total number of objects managed by the slab allocator.
unsigned | free_objects () const noexcept
| Get the number of free objects in the slab allocator.

## Additional Inherited Members

Public Types inherited from cxx::Base_slab_static< sizeof(Type), L4_PAGESIZE, 2, New_allocator >

## Detailed Description

template<typename Type, int Slab_size = L4_PAGESIZE, int Max_free = 2, template< typename A > class Alloc = New_allocator>
class cxx::Slab_static< Type, Slab_size, Max_free, Alloc >

Merged slab allocator (allocators for objects of the same size are merged together).

Template Parameters

  Type | The type of the objects to manage.
  Slab_size | The size of a slab.
  Max_free | The maximum number of free slabs.
  Alloc | The allocator for the slabs.

This slab allocator class is useful for merging slab allocators with the same parameters (equal sizeof(Type), Slab_size, Max_free, and Alloc parameters) together and share the overhead for the slab caches among all equal-sized objects.

Definition at line 465 of file slab_alloc.

## Member Function Documentation

## alloc()

template<typename Type, int Slab_size = L4_PAGESIZE, int Max_free = 2, template< typename A > class Alloc = New_allocator>

Type * cxx::Slab_static< Type, Slab_size, Max_free, Alloc >::alloc | ( |  | ) |

inlinenoexcept

Allocate an object of type Type.

Returns
  A pointer to the just allocated object, or 0 on failure.

Note
  The object is not zeroed out by the slab allocator.

Definition at line 478 of file slab_alloc.

References alloc().

Referenced by alloc().

Here is the call graph for this function:
Here is the caller graph for this function:

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

- l4/cxx/slab_alloc