mutek/slab.h header reference
[Kernel services module]
The source code of this header can be browsed online.
Description [link]
Slab allocator is a specialized memory allocator able to efficiently allocate buffers of fixed size.
Members [link]
Types [link]
- typedef [...] * slab_group_list_item_t
- typedef size_t (slab_grow_func_t)(struct slab_s *slab, size_t current)
- struct slab_s
- typedef [...] * slab_unit_list_item_t
- struct slab_group_s
- struct slab_unit_s
Functions [link]
- void * slab_alloc(struct slab_s *slab)
- void slab_cleanup(struct slab_s *slab)
- void slab_free(struct slab_s *slab, void *ptr)
- void slab_init(struct slab_s *slab, size_t unit_size, slab_grow_func_t *grow, enum mem_scope_e scope)
- void * slab_nolock_grow(struct slab_s *slab)
Macro [link]
Members detail [link]
#define SLAB_GROW(f) [link]
This macro is declared in mutek/slab.h source file, line 76.
this macro defines the grow policy function prototype for a slab.
This function is called every time the slab needs to grow.
Parameter list:
- slab: Slab to grow for
- current: Current allocator item count
The return value is count of items to allocate next
#define SLAB_H_ [link]
This macro is declared in mutek/slab.h source file, line 30.
This function is declared in mutek/slab.h source file, line 134.
this function allocates one element in the slab.
Parameter list:
- slab: The slab allocator
The return value is a newly allocated item
This function is declared in mutek/slab.h source file, line 119.
this function clears the slab.
After calling this function, you may not use any allocated items any more.
Parameter list:
- slab: Slab to destroy
This function is declared in mutek/slab.h source file, line 157.
this function deallocs one element in the slab.
Parameter list:
- slab: Slab the pointer belongs to
- ptr: Pointer to deallocate
typedef void * slab_group_list_entry_t [link]
This typedef is declared in mutek/slab.h source file, line 64.
typedef struct slab_group_s * slab_group_list_item_t [link]
This typedef is declared in mutek/slab.h source file, line 64.
typedef void * slab_group_list_root_t [link]
This typedef is declared in mutek/slab.h source file, line 64.
This typedef is declared in mutek/slab.h source file, line 79.
This declaration involves expansion of the SLAB_GROW macro.
void slab_init(struct slab_s *slab, size_t unit_size, slab_grow_func_t *grow, enum mem_scope_e scope) [link]
This function is declared in mutek/slab.h source file, line 109.
this function initializes a new slab.
Parameter list:
- slab: Slab structure to initialize
- unit_size: Size for each allocated item
- grow: Grow policy function
- scope: Memory allocator scope
struct slab_s [link]
This struct is declared in mutek/slab.h source file, line 81.
Field | Description |
---|---|
lock_t lock; | |
slab_group_list_root_t group_list; | |
slab_unit_list_root_t unit_list; | |
size_t unit_size; | |
size_t current_count; | |
slab_grow_func_t * grow; | |
enum mem_scope_e scope; |
typedef void * slab_unit_list_entry_t [link]
This typedef is declared in mutek/slab.h source file, line 56.
typedef struct slab_unit_s * slab_unit_list_item_t [link]
This typedef is declared in mutek/slab.h source file, line 56.
typedef void * slab_unit_list_root_t [link]
This typedef is declared in mutek/slab.h source file, line 56.
#define GCT_CONTAINER_ALGO_slab_group_list [link]
This macro is declared in mutek/slab.h source file, line 47.
This macro is for internal use only.
#define GCT_CONTAINER_ALGO_slab_unit_list [link]
This macro is declared in mutek/slab.h source file, line 45.
This macro is for internal use only.
struct slab_group_s [link]
This struct is declared in mutek/slab.h source file, line 59.
This struct is for internal use only.
This struct is empty.
See also slab_group_list_item_t.
This function is declared in mutek/slab.h source file, line 124.
Grow slab and return one allocated item
This function is for internal use only.
struct slab_unit_s [link]
This struct is declared in mutek/slab.h source file, line 51.
This struct is for internal use only.
This struct is empty.
See also slab_unit_list_item_t.