|
Revision 1032, 1.8 kB
(checked in by shawnw, 1 year ago)
|
Merged 1.8.3p4 into trunk
|
| Line | |
|---|
| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
#ifndef _MYMALLOC_H |
|---|
| 6 |
#define _MYMALLOC_H |
|---|
| 7 |
|
|---|
| 8 |
#include "options.h" |
|---|
| 9 |
|
|---|
| 10 |
#if (MALLOC_PACKAGE == 1) |
|---|
| 11 |
#define CSRI |
|---|
| 12 |
#elif (MALLOC_PACKAGE == 2) |
|---|
| 13 |
#include <stdlib.h> |
|---|
| 14 |
#define CSRI |
|---|
| 15 |
#define CSRI_TRACE |
|---|
| 16 |
#define CSRI_PROFILESIZES |
|---|
| 17 |
#define CSRI_DEBUG |
|---|
| 18 |
#include "csrimalloc.h" |
|---|
| 19 |
#endif |
|---|
| 20 |
|
|---|
| 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, |
|---|
| 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, |
|---|
| 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, |
|---|
| 36 |
page if it is the only page allocated for |
|---|
| 37 |
that slab. Defaults to 0. */ |
|---|
| 38 |
|
|---|
| 39 |
SLAB_HINTLESS_THRESHOLD |
|---|
| 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 |
|
|---|
| 50 |
#endif |
|---|