ucx/allocator.h

changeset 50
ff194559eb41
child 52
34f50d0bada4
equal deleted inserted replaced
49:1771360b740d 50:ff194559eb41
1 #ifndef ALLOCATOR_H
2 #define ALLOCATOR_H
3
4 #include <stddef.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 */

mercurial