Parlib
Easing Cross-Platform Development of Next Generation Parallel Systems
Amplab

Table Of Contents

Previous topic

Memory Pools

Next topic

Atomic Memory Operations

This Page

Slab Memory Allocator

To access the slab allocator API, include the following header file:

#include <parlib/slab.h>

Types

struct slab_cache;
typedef struct slab_cache slab_cache_t;

typedef void (*slab_cache_ctor_t)(void *, size_t);
typedef void (*slab_cache_dtor_t)(void *, size_t);
struct slab_cache
slab_cache_t
slab_cache_ctor_t
slab_cache_dtor_t

API Calls

struct slab_cache *slab_cache_create(const char *name, size_t obj_size,
                                     int align, int flags,
                                     slab_cache_ctor_t ctor,
                                     slab_cache_dtor_t dtor);
void slab_cache_destroy(struct slab_cache *cp);
void *slab_cache_alloc(struct slab_cache *cp, int flags);
void slab_cache_free(struct slab_cache *cp, void *buf);
struct slab_cache *slab_cache_create(const char *name, size_t obj_size, int align, int flags, slab_cache_ctor_t ctor, slab_cache_dtor_t dtor)
void slab_cache_destroy(struct slab_cache *cp)
void *slab_cache_alloc(struct slab_cache *cp, int flags)
void slab_cache_free(struct slab_cache *cp, void *buf)