src/server/ucx/mempool.h

changeset 36
450d2d5f4735
parent 15
cff9c4101dd7
child 71
069c152f6272
equal deleted inserted replaced
35:4417619a9bbd 36:450d2d5f4735
2 * 2 *
3 */ 3 */
4 4
5 #ifndef MPOOL_H 5 #ifndef MPOOL_H
6 #define MPOOL_H 6 #define MPOOL_H
7
8 #include <stddef.h>
9 #include "allocator.h"
7 10
8 #ifdef __cplusplus 11 #ifdef __cplusplus
9 extern "C" { 12 extern "C" {
10 #endif 13 #endif
11 14
14 typedef struct { 17 typedef struct {
15 void **data; 18 void **data;
16 size_t ndata; 19 size_t ndata;
17 size_t size; 20 size_t size;
18 } UcxMempool; 21 } UcxMempool;
22
23 #define UCX_ALLOCATOR_MEMPOOL(pool) {pool, \
24 (ucx_allocator_malloc) ucx_mempool_malloc, \
25 (ucx_allocator_calloc) ucx_mempool_calloc, \
26 (ucx_allocator_realloc) ucx_mempool_realloc}
19 27
20 #define ucx_mempool_new_default() ucx_mempool_new(16) 28 #define ucx_mempool_new_default() ucx_mempool_new(16)
21 UcxMempool *ucx_mempool_new(size_t n); 29 UcxMempool *ucx_mempool_new(size_t n);
22 int ucx_mempool_chcap(UcxMempool *pool, size_t newcap); 30 int ucx_mempool_chcap(UcxMempool *pool, size_t newcap);
23 31

mercurial