gwion-util
utilities for the Gwion project
Loading...
Searching...
No Matches
mpool.h
Go to the documentation of this file.
1
5#ifndef __POOL
6#define __POOL
7
8typedef struct MemPool_ {
9 struct pool * master_pool;
10 struct pool **pools;
11 size_t * sizes;
12 size_t sz;
14
15ANN struct pool *new_pool(const uint32_t elementSize);
16ANN struct pool *mp_ini(MemPool p, const uint32_t elementSize);
17ANN void mp_end(struct pool *);
18ANEW ANN void *_mp_calloc2(struct pool *, const bool) __attribute__((hot));
21ANN void _mp_free(MemPool, const m_uint, void *);
22ANN void _mp_free2(struct pool *, void *);
23
24void *mp_realloc(MemPool mp, void *ptr, const m_uint curr, const m_uint next);
25#define mp_malloc(p, name) _mp_malloc(p, sizeof(struct name##_))
26#define mp_calloc(p, name) _mp_calloc(p, sizeof(struct name##_))
27#define mp_free(p, name, a) _mp_free(p, sizeof(struct name##_), (a))
28#define mp_free2(p, sz, a) _mp_free(p, sz, (a))
29#define mp_calloc2(p, sz) _mp_calloc(p, sz)
30#define mp_malloc2(p, sz) _mp_calloc(p, sz)
31
32MemPool mempool_ini(const size_t sz);
33void mempool_end(MemPool mp);
34#endif
#define ANN
Definition defs.h:19
#define ANEW
Definition defs.h:22
uintptr_t m_uint
Definition gwcommon.h:11
__attribute__((hot, pure))
Definition hash.c:20
ANN void _mp_free(MemPool, const m_uint, void *)
Definition mpool.c:124
void * mp_realloc(MemPool mp, void *ptr, const m_uint curr, const m_uint next)
Definition mpool.c:148
ANEW ANN void * _mp_malloc(MemPool, const m_uint) __attribute__((hot))
MemPool mempool_ini(const size_t sz)
Definition mpool.c:35
void mempool_end(MemPool mp)
Definition mpool.c:45
ANN struct pool * mp_ini(MemPool p, const uint32_t elementSize)
Definition mpool.c:66
ANN struct pool * new_pool(const uint32_t elementSize)
Definition mpool.c:132
ANN void _mp_free2(struct pool *, void *)
Definition mpool.c:113
ANEW ANN void * _mp_calloc(MemPool, const m_uint) __attribute__((hot))
ANEW ANN void * _mp_calloc2(struct pool *, const bool) __attribute__((hot))
Definition mpool.c:106
ANN void mp_end(struct pool *)
Definition mpool.c:74
struct MemPool_ * MemPool
size_t * sizes
Definition mpool.h:11
struct pool ** pools
Definition mpool.h:10
struct pool * master_pool
Definition mpool.h:9
size_t sz
Definition mpool.h:12
Definition mpool.c:15
volatile struct Recycle * next
Definition mpool.c:18