gwion-util
utilities for the Gwion project
Loading...
Searching...
No Matches
mpool.h
Go to the documentation of this file.
1
4#pragma once
5
6typedef struct MemPool_ {
7 struct pool * master_pool;
8 struct pool **pools;
9 size_t * sizes;
10 size_t sz;
12
13ANN struct pool *new_pool(const uint32_t elementSize);
14ANN struct pool *mp_ini(MemPool p, const uint32_t elementSize);
15ANN void mp_end(struct pool *);
16ANEW ANN void *_mp_calloc2(struct pool *, const bool) __attribute__((hot));
19ANN void _mp_free(MemPool, const m_uint, void *);
20ANN void _mp_free2(struct pool *, void *);
21
22void *mp_realloc(MemPool mp, void *ptr, const m_uint curr, const m_uint next);
23#define mp_malloc(p, name) _mp_malloc(p, sizeof(struct name##_))
24#define mp_calloc(p, name) _mp_calloc(p, sizeof(struct name##_))
25#define mp_free(p, name, a) _mp_free(p, sizeof(struct name##_), (a))
26#define mp_free2(p, sz, a) _mp_free(p, sz, (a))
27#define mp_calloc2(p, sz) _mp_calloc(p, sz)
28#define mp_malloc2(p, sz) _mp_calloc(p, sz)
29
30MemPool mempool_ini(const size_t sz);
31void mempool_end(MemPool mp);
#define ANN
Definition defs.h:18
#define ANEW
Definition defs.h:21
uintptr_t m_uint
Definition gwcommon.h:12
__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:9
struct pool ** pools
Definition mpool.h:8
struct pool * master_pool
Definition mpool.h:7
size_t sz
Definition mpool.h:10
Definition mpool.c:15
volatile struct Recycle * next
Definition mpool.c:18