ucx/allocator.h

changeset 1
1bcaac272cdf
child 5
88625853ae74
equal deleted inserted replaced
0:0f94d369bb02 1:1bcaac272cdf
1 #ifndef ALLOCATOR_H
2 #define ALLOCATOR_H
3
4 #include "ucx.h"
5
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9
10 typedef void*(*ucx_allocator_malloc)(void *pool, size_t n);
11 typedef void*(*ucx_allocator_calloc)(void *pool, size_t n, size_t size);
12 typedef void*(*ucx_allocator_realloc)(void *pool, void *data, size_t n);
13
14 typedef struct {
15 void *pool;
16 ucx_allocator_malloc malloc;
17 ucx_allocator_calloc calloc;
18 ucx_allocator_realloc realloc;
19 } UcxAllocator;
20
21 void *ucx_default_malloc(void *ignore, size_t n);
22 void *ucx_default_calloc(void *ignore, size_t n, size_t size);
23 void *ucx_default_realloc(void *ignore, void *data, size_t n);
24
25 #define UCX_ALLOCATOR_DEFAULT {NULL, \
26 ucx_default_malloc, ucx_default_calloc, ucx_default_realloc}
27
28 #ifdef __cplusplus
29 }
30 #endif
31
32 #endif /* ALLOCATOR_H */
33

mercurial