Adaptive Framework  0.9.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
afw_pool.h
Go to the documentation of this file.
1 // See the 'COPYING' file in the project root for licensing information.
2 /*
3  * Adaptive Framework memory pool support header.
4  *
5  * Copyright (c) 2010-2023 Clemson University
6  *
7  */
8 
9 #ifndef __AFW_POOL_H__
10 #define __AFW_POOL_H__
11 
12 #include "afw_interface.h"
13 
29 
32 
33 
36 
37  /* *** next_cleanup MUST BE FIRST *** */
40 
41  /* @brief Cleanup function. */
43 
44  /* @brief Parameter data passed to function. */
45  void *data;
46 
47  /* @brief Parameter data2 passed to function. */
48  void *data2;
49 };
50 
51 
52 
72 AFW_DECLARE(const afw_pool_t *)
73 afw_pool_create(const afw_pool_t *parent, afw_xctx_t *xctx);
74 
75 
84 AFW_DECLARE(const afw_pool_t *)
85 afw_pool_create_debug(const afw_pool_t *parent,
86  afw_xctx_t *xctx, const afw_utf8_z_t *source_z);
87 
88 
89 #ifdef AFW_POOL_DEBUG
90 #define afw_pool_create(parent,xctx) \
91  afw_pool_create_debug(parent, xctx, AFW__FILE_LINE__)
92 #endif
93 
94 
132 AFW_DECLARE(const afw_pool_t *)
134 
135 
144 AFW_DECLARE(const afw_pool_t *)
146  afw_xctx_t *xctx, const afw_utf8_z_t *source_z);
147 
148 
149 #ifdef AFW_POOL_DEBUG
150 #define afw_pool_create_multithreaded(parent,xctx) \
151  afw_pool_create_multithreaded_debug(parent, xctx, AFW__FILE_LINE__)
152 #endif
153 
154 
155 
167 #define afw_pool_calloc_type(instance, type, xctx) \
168  (type *) afw_pool_calloc(instance, sizeof(type), xctx)
169 
170 
182 #define afw_pool_malloc_type(instance, type, xctx) \
183  (type *) afw_pool_malloc(instance, sizeof(type), xctx)
184 
185 
186 #ifdef AFW_POOL_DEBUG
187 
188 #undef afw_pool_release
189 #define afw_pool_release(instance,xctx) \
190  afw_pool_release_debug(instance, xctx, AFW__FILE_LINE__)
191 
192 #undef afw_pool_destroy
193 #define afw_pool_destroy(instance,xctx) \
194  afw_pool_destroy_debug(instance, xctx, AFW__FILE_LINE__)
195 
196 #undef afw_pool_add_reference
197 #define afw_pool_add_reference(instance,xctx) \
198  afw_pool_add_reference_debug(instance, xctx, AFW__FILE_LINE__)
199 
200 #undef afw_pool_calloc
201 #define afw_pool_calloc(instance,size,xctx) \
202  afw_pool_calloc_debug(instance, size, xctx, AFW__FILE_LINE__)
203 
204 #undef afw_pool_malloc
205 #define afw_pool_malloc(instance,size,xctx) \
206  afw_pool_malloc_debug(instance, size, xctx, AFW__FILE_LINE__)
207 
208 #undef afw_pool_free
209 #define afw_pool_free(instance,size,xctx) \
210  afw_pool_free_debug(instance, size, xctx, AFW__FILE_LINE__)
211 
212 #undef afw_pool_register_cleanup_before
213 #define afw_pool_register_cleanup_before(instance,data,data2,cleanup,xctx) \
214  afw_pool_register_cleanup_before_debug(instance, data, data2, cleanup, \
215  xctx, AFW__FILE_LINE__)
216 
217 #undef afw_pool_deregister_cleanup
218 #define afw_pool_deregister_cleanup(instance,data,data2,cleanup,xctx) \
219  afw_pool_deregister_cleanup_debug(instance, data, data2, cleanup, \
220  xctx, AFW__FILE_LINE__)
221 
222 #endif
223 
224 
225 AFW_END_DECLARES
226 
229 #endif /* __AFW_POOL_H__ */
#define AFW_BEGIN_DECLARES
#define AFW_DECLARE(type)
Declare a public afw function.
Interfaceafw_interface header.
afw_utf8_octet_t afw_utf8_z_t
NFC normalized UTF-8 null terminated string.
Definition: afw_common.h:523
void(* afw_pool_cleanup_function_p_t)(void *data, void *data2, const afw_pool_t *p, afw_xctx_t *xctx)
Typedef for pool cleanup functions.
Definition: afw_common.h:954
const afw_pool_t * afw_pool_create(const afw_pool_t *parent, afw_xctx_t *xctx)
Create a new pool.
const afw_pool_t * afw_pool_create_multithreaded(const afw_pool_t *parent, afw_xctx_t *xctx)
Create a new multithreaded pool.
const afw_pool_t * afw_pool_create_multithreaded_debug(const afw_pool_t *parent, afw_xctx_t *xctx, const afw_utf8_z_t *source_z)
Debug version of create a new multithreaded pool.
const afw_pool_t * afw_pool_create_debug(const afw_pool_t *parent, afw_xctx_t *xctx, const afw_utf8_z_t *source_z)
Debug version of create a new pool.
Struct for registered cleanup functions.
Definition: afw_pool.h:35
afw_pool_cleanup_t * next_cleanup
Next cleanup function.
Definition: afw_pool.h:39
Interface afw_pool public struct.
Interface afw_xctx public struct.