Go to the source code of this file.
|
static ANN void | mp_set (struct pool *p, const uint32_t obj_sz) |
|
MemPool | mempool_ini (const size_t sz) |
|
void | mempool_end (MemPool mp) |
|
static struct pool * | mp_create (MemPool mp, const uint32_t obj_sz, const uint32_t idx) |
|
ANN struct pool * | mp_ini (MemPool mp, const uint32_t obj_sz) |
|
void | mp_end (struct pool *p) |
|
static void | _realloc (struct pool *p) |
|
static void * | __mp_calloc2 (struct pool *p, const bool zero) |
|
void * | _mp_calloc2 (struct pool *p, const bool zero) |
|
void | _mp_free2 (struct pool *p, void *ptr) |
|
void | _mp_free (MemPool mp, const m_uint size, void *ptr) |
|
struct pool * | new_pool (const uint32_t obj_sz) |
|
void * | mp_realloc (MemPool mp, void *ptr, const m_uint curr, const m_uint next) |
|
◆ BIG_BLK
◆ BLK
◆ MP_ALLOC
#define MP_ALLOC |
( |
| name, |
|
|
| zero, |
|
|
| default ) |
Value:
void * ret = p ?
_mp_calloc2(p, zero) : (void *)default; \
return ret; \
}
ANN struct pool * mp_ini(MemPool mp, const uint32_t obj_sz)
void * _mp_calloc2(struct pool *p, const bool zero)
Definition at line 138 of file mpool.c.
138#define MP_ALLOC(name, zero, default) \
139 void *_mp_##name(MemPool mp, const m_uint size) { \
140 struct pool *p = mp_ini(mp, size); \
141 void * ret = p ? _mp_calloc2(p, zero) : (void *)default; \
142 return ret; \
143 }
◆ MPHUGE
◆ SMALL_BLK
◆ __mp_calloc2()
static void * __mp_calloc2 |
( |
struct pool * | p, |
|
|
const bool | zero ) |
|
static |
Definition at line 92 of file mpool.c.
92 {
95 #ifdef USE_HELGRIND
96 VALGRIND_HG_CLEAN_MEMORY(recycle, p->
obj_sz);
97 #endif
99 if (zero) memset((
void*)recycle, 0, p->
obj_sz);
100 return (void*)recycle;
101 }
104}
static void _realloc(struct pool *p)
volatile struct Recycle * next
volatile struct Recycle * next
◆ _mp_calloc2()
void * _mp_calloc2 |
( |
struct pool * | p, |
|
|
const bool | zero ) |
Definition at line 106 of file mpool.c.
106 {
110 return ret;
111}
static void * __mp_calloc2(struct pool *p, const bool zero)
static ANN int gwt_unlock(gwtlock_t *lock)
static ANN int gwt_lock(gwtlock_t *lock)
◆ _mp_free()
Definition at line 124 of file mpool.c.
124 {
126 if (p)
128 else
130}
void _mp_free2(struct pool *p, void *ptr)
◆ _mp_free2()
void _mp_free2 |
( |
struct pool * | p, |
|
|
void * | ptr ) |
Definition at line 113 of file mpool.c.
113 {
116#ifdef POOL_CHECK
117 memset(ptr, 0, p->
obj_sz);
118#endif
122}
◆ _realloc()
static void _realloc |
( |
struct pool * | p | ) |
|
|
static |
Definition at line 80 of file mpool.c.
80 {
83 const uint32_t nblk = p->
nblk + 1;
86 for (uint32_t i = nblk; i < p->
nblk; ++i)
88 }
90}
static ANEW void * xcalloc(const m_uint n, const m_uint sz)
static ANEW void * xrealloc(void *p, const m_uint sz)
◆ mempool_end()
Definition at line 45 of file mpool.c.
45 {
50 }
56}
void mp_end(struct pool *p)
struct pool * master_pool
◆ mempool_ini()
MemPool mempool_ini |
( |
const size_t | sz | ) |
|
Definition at line 35 of file mpool.c.
35 {
40 for (
size_t j =
SZ_INT, k = 0; sz >= k; k = j, j <<= 1) p->
sizes[p->
sz++] = j;
42 return p;
43}
struct pool * new_pool(const uint32_t obj_sz)
struct MemPool_ * MemPool
static ANEW void * xmalloc(const m_uint sz)
◆ mp_create()
static struct pool * mp_create |
( |
MemPool | mp, |
|
|
const uint32_t | obj_sz, |
|
|
const uint32_t | idx ) |
|
inlinestatic |
Definition at line 58 of file mpool.c.
59 {
63 return p;
64}
static ANN void mp_set(struct pool *p, const uint32_t obj_sz)
◆ mp_end()
void mp_end |
( |
struct pool * | p | ) |
|
Definition at line 74 of file mpool.c.
74 {
78}
static ANN void gwt_lock_end(gwtlock_t *lock)
◆ mp_ini()
Definition at line 66 of file mpool.c.
66 {
67 for (
size_t i = 0; i < mp->
sz; ++i) {
68 if (obj_sz <= mp->sizes[i])
70 }
71 return NULL;
72}
static struct pool * mp_create(MemPool mp, const uint32_t obj_sz, const uint32_t idx)
◆ mp_realloc()
Definition at line 148 of file mpool.c.
148 {
150 if (ret != ptr) memcpy(ret, ptr, curr);
152 return ret;
153}
#define mp_free2(p, sz, a)
ANEW ANN void * _mp_malloc(MemPool, const m_uint) __attribute__((hot))
◆ mp_set()
static ANN void mp_set |
( |
struct pool * | p, |
|
|
const uint32_t | obj_sz ) |
|
static |
Definition at line 25 of file mpool.c.
25 {
31 p->
data = (uint8_t **)
xcalloc(1,
sizeof(uint8_t *));
33}
static ANN int gwt_lock_ini(gwtlock_t *lock)
◆ new_pool()
struct pool * new_pool |
( |
const uint32_t | obj_sz | ) |
|