| | 21 | typedef struct slab slab; |
|---|
| | 22 | slab *slab_create(const char *name, size_t item_size); |
|---|
| | 23 | void slab_destroy(slab *); |
|---|
| | 24 | void *slab_malloc(slab *sl, const void *hint); |
|---|
| | 25 | void slab_free(slab *sl, void *obj); |
|---|
| | 26 | |
|---|
| | 27 | enum slab_options { |
|---|
| | 28 | SLAB_ALLOC_FIRST_FIT, /**< When allocating without a hint (Or when a |
|---|
| | 29 | hint page is full) , use the first page |
|---|
| | 30 | found with room for the object. Default. Mutually exclusive with SLAB_ALLOC_BEST_FIT. */ |
|---|
| | 31 | SLAB_ALLOC_BEST_FIT, /**< When allocating without a hint (Or when a |
|---|
| | 32 | hint page is full), use the page with the |
|---|
| | 33 | fewest free objects. Mutually exclusive with SLAB_ALLOC_FIRST_FIT. */ |
|---|
| | 34 | |
|---|
| | 35 | SLAB_ALWAYS_KEEP_A_PAGE, /**< If set to 1, do not delete an empty |
|---|
| | 36 | page if it is the only page allocated for |
|---|
| | 37 | that slab. Defaults to 0. */ |
|---|
| | 38 | |
|---|
| | 39 | SLAB_HINTLESS_THRESHOLD /**< The number of free objects that must |
|---|
| | 40 | exist in a page for a hintless object to |
|---|
| | 41 | be allocated from it. Defaults to |
|---|
| | 42 | 1. Raise for cases where you'll have a |
|---|
| | 43 | lot of allocations using hints and |
|---|
| | 44 | deletions, to improve caching -- e.g., |
|---|
| | 45 | attributes. */ |
|---|
| | 46 | }; |
|---|
| | 47 | |
|---|
| | 48 | void slab_set_opt(slab *sl, enum slab_options opt, int val); |
|---|
| | 49 | |
|---|