diff options
author | Alex Auvolat <alex@adnab.me> | 2016-07-15 23:12:14 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2016-07-15 23:12:14 +0200 |
commit | 32407e728971006ed3d0885e01c22fb66c8adc57 (patch) | |
tree | 89483d39e8e2638383f815d4e73b647334fe2fe9 /src/common/include/slab_alloc.h | |
parent | ba4e59a1d687173ac5cfa74d26d71d6059dc6bc6 (diff) | |
download | kogata-32407e728971006ed3d0885e01c22fb66c8adc57.tar.gz kogata-32407e728971006ed3d0885e01c22fb66c8adc57.zip |
Move stuff around, again
Diffstat (limited to 'src/common/include/slab_alloc.h')
-rw-r--r-- | src/common/include/slab_alloc.h | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/src/common/include/slab_alloc.h b/src/common/include/slab_alloc.h deleted file mode 100644 index c8d5d6c..0000000 --- a/src/common/include/slab_alloc.h +++ /dev/null @@ -1,45 +0,0 @@ -#pragma once - -// Self-contained piece of library : a slab allocator... -// Depends on page_alloc_fun_t and page_free_fun_t : a couple of functions -// that can allocate/free multiples of one page at a time - -#include <stdint.h> -#include <stddef.h> -#include <stdbool.h> - - -#if defined(__linux__) -//redefine necessary stuff -#include <assert.h> // standard linux assert.h -#define ASSERT assert -#include <stdio.h> -#define dbg_printf printf -#else -#include <debug.h> -#endif - -#define PAGE_SIZE 0x1000 - -// expected format for the array of slab_type_t given to slab_create : -// an array of slab_type descriptors, with last descriptor full of zeroes -// and with obj_size increasing (strictly) in the array -typedef struct slab_type { - const char *descr; - size_t obj_size; - size_t pages_per_cache; -} slab_type_t; - -struct mem_allocator; -typedef struct mem_allocator mem_allocator_t; - -typedef void* (*page_alloc_fun_t)(size_t bytes); -typedef void (*page_free_fun_t)(void* ptr); - -mem_allocator_t* create_slab_allocator(const slab_type_t *types, page_alloc_fun_t af, page_free_fun_t ff); -void destroy_slab_allocator(mem_allocator_t*); - -void* slab_alloc(mem_allocator_t* a, size_t sz); -void slab_free(mem_allocator_t* a, void* ptr); - -/* vim: set ts=4 sw=4 tw=0 noet :*/ |