1179:ca4c6f590a08 | 1180:4c3a69b9723a |
---|---|
98 typedef struct cx_allocator_s CxAllocator; | 98 typedef struct cx_allocator_s CxAllocator; |
99 | 99 |
100 /** | 100 /** |
101 * A default allocator using standard library malloc() etc. | 101 * A default allocator using standard library malloc() etc. |
102 */ | 102 */ |
103 extern CxAllocator *cxDefaultAllocator; | 103 cx_attr_export |
104 extern const CxAllocator * const cxDefaultAllocator; | |
104 | 105 |
105 /** | 106 /** |
106 * Function pointer type for destructor functions. | 107 * Function pointer type for destructor functions. |
107 * | 108 * |
108 * A destructor function deallocates possible contents and MAY free the memory | 109 * A destructor function deallocates possible contents and MAY free the memory |
143 * @retval non-zero failure | 144 * @retval non-zero failure |
144 * @see cx_reallocatearray() | 145 * @see cx_reallocatearray() |
145 */ | 146 */ |
146 cx_attr_nonnull | 147 cx_attr_nonnull |
147 cx_attr_nodiscard | 148 cx_attr_nodiscard |
149 cx_attr_export | |
148 int cx_reallocate_( | 150 int cx_reallocate_( |
149 void **mem, | 151 void **mem, |
150 size_t n | 152 size_t n |
151 ); | 153 ); |
152 | 154 |
167 * @retval non-zero failure | 169 * @retval non-zero failure |
168 * @see cx_reallocate() | 170 * @see cx_reallocate() |
169 */ | 171 */ |
170 cx_attr_nonnull | 172 cx_attr_nonnull |
171 cx_attr_nodiscard | 173 cx_attr_nodiscard |
174 cx_attr_export | |
172 int cx_reallocatearray_( | 175 int cx_reallocatearray_( |
173 void **mem, | 176 void **mem, |
174 size_t nmemb, | 177 size_t nmemb, |
175 size_t size | 178 size_t size |
176 ); | 179 ); |
216 * | 219 * |
217 * @param allocator the allocator | 220 * @param allocator the allocator |
218 * @param mem a pointer to the block to free | 221 * @param mem a pointer to the block to free |
219 */ | 222 */ |
220 cx_attr_nonnull_arg(1) | 223 cx_attr_nonnull_arg(1) |
224 cx_attr_export | |
221 void cxFree( | 225 void cxFree( |
222 const CxAllocator *allocator, | 226 const CxAllocator *allocator, |
223 void *mem | 227 void *mem |
224 ); | 228 ); |
225 | 229 |
233 cx_attr_nodiscard | 237 cx_attr_nodiscard |
234 cx_attr_nonnull | 238 cx_attr_nonnull |
235 cx_attr_malloc | 239 cx_attr_malloc |
236 cx_attr_dealloc_ucx | 240 cx_attr_dealloc_ucx |
237 cx_attr_allocsize(2) | 241 cx_attr_allocsize(2) |
242 cx_attr_export | |
238 void *cxMalloc( | 243 void *cxMalloc( |
239 const CxAllocator *allocator, | 244 const CxAllocator *allocator, |
240 size_t n | 245 size_t n |
241 ); | 246 ); |
242 | 247 |
255 */ | 260 */ |
256 cx_attr_nodiscard | 261 cx_attr_nodiscard |
257 cx_attr_nonnull_arg(1) | 262 cx_attr_nonnull_arg(1) |
258 cx_attr_dealloc_ucx | 263 cx_attr_dealloc_ucx |
259 cx_attr_allocsize(3) | 264 cx_attr_allocsize(3) |
265 cx_attr_export | |
260 void *cxRealloc( | 266 void *cxRealloc( |
261 const CxAllocator *allocator, | 267 const CxAllocator *allocator, |
262 void *mem, | 268 void *mem, |
263 size_t n | 269 size_t n |
264 ); | 270 ); |
283 */ | 289 */ |
284 cx_attr_nodiscard | 290 cx_attr_nodiscard |
285 cx_attr_nonnull_arg(1) | 291 cx_attr_nonnull_arg(1) |
286 cx_attr_dealloc_ucx | 292 cx_attr_dealloc_ucx |
287 cx_attr_allocsize(3, 4) | 293 cx_attr_allocsize(3, 4) |
294 cx_attr_export | |
288 void *cxReallocArray( | 295 void *cxReallocArray( |
289 const CxAllocator *allocator, | 296 const CxAllocator *allocator, |
290 void *mem, | 297 void *mem, |
291 size_t nmemb, | 298 size_t nmemb, |
292 size_t size | 299 size_t size |
308 * @retval zero success | 315 * @retval zero success |
309 * @retval non-zero failure | 316 * @retval non-zero failure |
310 */ | 317 */ |
311 cx_attr_nodiscard | 318 cx_attr_nodiscard |
312 cx_attr_nonnull | 319 cx_attr_nonnull |
320 cx_attr_export | |
313 int cxReallocate_( | 321 int cxReallocate_( |
314 const CxAllocator *allocator, | 322 const CxAllocator *allocator, |
315 void **mem, | 323 void **mem, |
316 size_t n | 324 size_t n |
317 ); | 325 ); |
354 * @retval zero success | 362 * @retval zero success |
355 * @retval non-zero on failure | 363 * @retval non-zero on failure |
356 */ | 364 */ |
357 cx_attr_nodiscard | 365 cx_attr_nodiscard |
358 cx_attr_nonnull | 366 cx_attr_nonnull |
367 cx_attr_export | |
359 int cxReallocateArray_( | 368 int cxReallocateArray_( |
360 const CxAllocator *allocator, | 369 const CxAllocator *allocator, |
361 void **mem, | 370 void **mem, |
362 size_t nmemb, | 371 size_t nmemb, |
363 size_t size | 372 size_t size |
396 cx_attr_nonnull_arg(1) | 405 cx_attr_nonnull_arg(1) |
397 cx_attr_nodiscard | 406 cx_attr_nodiscard |
398 cx_attr_malloc | 407 cx_attr_malloc |
399 cx_attr_dealloc_ucx | 408 cx_attr_dealloc_ucx |
400 cx_attr_allocsize(2, 3) | 409 cx_attr_allocsize(2, 3) |
410 cx_attr_export | |
401 void *cxCalloc( | 411 void *cxCalloc( |
402 const CxAllocator *allocator, | 412 const CxAllocator *allocator, |
403 size_t nelem, | 413 size_t nelem, |
404 size_t n | 414 size_t n |
405 ); | 415 ); |