MOS Source Code
Loading...
Searching...
No Matches
slab.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-3.0-or-later
2
3#pragma once
4
7#include <stddef.h>
8
10
17void *slab_alloc(size_t size);
18
26void *slab_calloc(size_t nmemb, size_t size);
27
35void *slab_realloc(void *addr, size_t size);
36
42void slab_free(const void *addr);
43
44typedef struct
45{
49 size_t ent_size;
50 const char *name;
51 size_t nobjs;
52} slab_t;
53
54slab_t *kmemcache_create(const char *name, size_t ent_size);
55void *kmemcache_alloc(slab_t *slab);
56
#define __END_DECLS
Definition mos_global.h:23
#define __BEGIN_DECLS
Definition mos_global.h:22
size_t size
Definition slab.c:30
const char * name
Definition slab.c:31
slab_t * kmemcache_create(const char *name, size_t ent_size)
Definition slab.c:219
void * slab_realloc(void *addr, size_t size)
Reallocate a block of memory from the slab allocator.
Definition slab.c:158
void slab_free(const void *addr)
Free a block of memory from the slab allocator.
Definition slab.c:200
void * kmemcache_alloc(slab_t *slab)
Definition slab.c:227
__BEGIN_DECLS void * slab_alloc(size_t size)
Allocate a block of memory from the slab allocator.
Definition slab.c:130
void * slab_calloc(size_t nmemb, size_t size)
Allocate a block of memory from the slab allocator and zero it.
Definition slab.c:148
Definition slab.h:45
as_linked_list
Definition slab.h:46
size_t nobjs
Definition slab.h:51
spinlock_t lock
Definition slab.h:47
ptr_t first_free
Definition slab.h:48
const char * name
Definition slab.h:50
size_t ent_size
Definition slab.h:49
unsigned long ptr_t
Definition types.h:25