Subversion リポジトリの参照
Contents of /slabs.h
Parent Directory
| Revision Log
Revision 1 -
( show annotations)
( download)
( as text)
Sun Jul 11 05:43:29 2010 UTC
(13 years, 10 months ago)
by tullio
File MIME type: text/x-chdr
File size: 1160 byte(s)
first import
1 |
/* slabs memory allocation */ |
2 |
#ifndef SLABS_H |
3 |
#define SLABS_H |
4 |
|
5 |
/** Init the subsystem. 1st argument is the limit on no. of bytes to allocate, |
6 |
0 if no limit. 2nd argument is the growth factor; each slab will use a chunk |
7 |
size equal to the previous slab's chunk size times this factor. |
8 |
3rd argument specifies if the slab allocator should allocate all memory |
9 |
up front (if true), or allocate memory in chunks as it is needed (if false) |
10 |
*/ |
11 |
void slabs_init(const size_t limit, const double factor, const bool prealloc); |
12 |
|
13 |
|
14 |
/** |
15 |
* Given object size, return id to use when allocating/freeing memory for object |
16 |
* 0 means error: can't store such a large object |
17 |
*/ |
18 |
|
19 |
unsigned int slabs_clsid(const size_t size); |
20 |
|
21 |
/** Allocate object of given length. 0 on error */ /*@null@*/ |
22 |
void *slabs_alloc(const size_t size, unsigned int id); |
23 |
|
24 |
/** Free previously allocated object */ |
25 |
void slabs_free(void *ptr, size_t size, unsigned int id); |
26 |
|
27 |
/** Return a datum for stats in binary protocol */ |
28 |
bool get_stats(const char *stat_type, int nkey, ADD_STAT add_stats, void *c); |
29 |
|
30 |
/** Fill buffer with stats */ /*@null@*/ |
31 |
void slabs_stats(ADD_STAT add_stats, void *c); |
32 |
|
33 |
#endif |
| |