22 #ifndef ETCPAL_MEMPOOL_H_
23 #define ETCPAL_MEMPOOL_H_
26 #include "etcpal/error.h"
89 typedef struct EtcPalMempool EtcPalMempool;
106 typedef struct EtcPalMempoolDesc
108 const size_t elem_size;
109 const size_t pool_size;
110 EtcPalMempool* freelist;
111 EtcPalMempool*
const list;
126 #define ETCPAL_MEMPOOL_DECLARE(name) extern EtcPalMempoolDesc name##_pool_desc;
139 #define ETCPAL_MEMPOOL_DEFINE(name, type, size) \
140 type name##_pool[size]; \
141 struct EtcPalMempool name##_pool_list[size]; \
142 struct EtcPalMempoolDesc name##_pool_desc = {sizeof(type), \
160 #define ETCPAL_MEMPOOL_DEFINE_ARRAY(name, type, array_size, pool_size) \
161 type name##_pool[array_size][pool_size]; \
162 struct EtcPalMempool name##_pool_list[pool_size]; \
163 struct EtcPalMempoolDesc name##_pool_desc = {sizeof(type[array_size]), \
181 #define etcpal_mempool_init(name) etcpal_mempool_init_priv(&name##_pool_desc)
188 #define etcpal_mempool_alloc(name) etcpal_mempool_alloc_priv(&name##_pool_desc)
200 #define etcpal_mempool_free(name, mem) etcpal_mempool_free_priv(&name##_pool_desc, mem)
210 #define etcpal_mempool_size(name) (name##_pool_desc.pool_size)
217 #define etcpal_mempool_used(name) etcpal_mempool_used_priv(&name##_pool_desc)
222 void* etcpal_mempool_alloc_priv(EtcPalMempoolDesc* desc);
223 void etcpal_mempool_free_priv(EtcPalMempoolDesc* desc,
void* elem);
224 size_t etcpal_mempool_used_priv(EtcPalMempoolDesc* desc);
etcpal_error_t
A set of error codes that can be returned by library functions.
Definition: error.h:49