root/1.8.3/tags/p6/hdrs/mymalloc.h

Revision 1032, 1.8 KB (checked in by shawnw, 18 months ago)

Merged 1.8.3p4 into trunk

Line 
1/* A wrapper header that sets up the proper defines based on
2 * options.h's MALLOC_PACKAGE
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
21typedef struct slab slab;
22slab *slab_create(const char *name, size_t item_size);
23void slab_destroy(slab *);
24void *slab_malloc(slab *sl, const void *hint);
25void slab_free(slab *sl, void *obj);
26
27enum 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
48void slab_set_opt(slab *sl, enum slab_options opt, int val);
49
50#endif                          /* _MYMALLOC_H */
Note: See TracBrowser for help on using the browser.