17 void **data; |
18 void **data; |
18 size_t ndata; |
19 size_t ndata; |
19 size_t size; |
20 size_t size; |
20 } UcxMempool; |
21 } UcxMempool; |
21 |
22 |
22 typedef void*(*ucx_allocator_malloc)(UcxMempool *pool, size_t n); |
|
23 typedef void*(*ucx_allocator_calloc)(UcxMempool *pool, size_t n, size_t size); |
|
24 typedef void*(*ucx_allocator_realloc)(UcxMempool *pool, void *data, size_t n); |
|
25 |
|
26 typedef struct { |
|
27 UcxMempool *pool; |
|
28 ucx_allocator_malloc malloc; |
|
29 ucx_allocator_calloc calloc; |
|
30 ucx_allocator_realloc realloc; |
|
31 } UcxAllocator; |
|
32 |
|
33 #define UCX_ALLOCATOR_DEFAULT {NULL, \ |
|
34 ucx_default_malloc, ucx_default_calloc, ucx_default_realloc} |
|
35 #define UCX_ALLOCATOR_MEMPOOL(pool) {pool, \ |
23 #define UCX_ALLOCATOR_MEMPOOL(pool) {pool, \ |
36 ucx_mempool_malloc, ucx_mempool_calloc, ucx_mempool_realloc} |
24 (ucx_allocator_malloc) ucx_mempool_malloc, \ |
37 |
25 (ucx_allocator_calloc) ucx_mempool_calloc, \ |
38 void *ucx_default_malloc(UcxMempool *ignore, size_t n); |
26 (ucx_allocator_realloc) ucx_mempool_realloc} |
39 void *ucx_default_calloc(UcxMempool *ignore, size_t n, size_t size); |
|
40 void *ucx_default_realloc(UcxMempool *ignore, void *data, size_t n); |
|
41 |
27 |
42 #define ucx_mempool_new_default() ucx_mempool_new(16) |
28 #define ucx_mempool_new_default() ucx_mempool_new(16) |
43 UcxMempool *ucx_mempool_new(size_t n); |
29 UcxMempool *ucx_mempool_new(size_t n); |
44 int ucx_mempool_chcap(UcxMempool *pool, size_t newcap); |
30 int ucx_mempool_chcap(UcxMempool *pool, size_t newcap); |
45 |
31 |