summaryrefslogblamecommitdiffstats
path: root/mem/slab.h
blob: 074d278d6bbf01c37f7bb983e04ba655782fe381 (plain) (tree)
































                                        
#ifndef JOVE_MEMORY_SLAB_H
#define JOVE_MEMORY_SLAB_H 1

#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>

#define SLABCACHE_NAME_LIMIT 32
struct SlabCache
{
    char name[SLABCACHE_NAME_LIMIT];

    struct SlabDescriptor *list_free;
    struct SlabDescriptor *list_partial;
    struct SlabDescriptor *list_full;

    size_t obj_size;
    size_t slab_pages;
};

struct SlabDescriptor
{
    struct SlabDescriptor *prev;
    struct SlabDescriptor *next;
    void *slab_base;
    void *obj_base;

    size_t free_count;
    int free_index;
    uintptr_t free[];
};

#endif