Wed, 02 Jan 2013 16:03:50 +0100
added access log
15
cff9c4101dd7
Replaced old utils with ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1 | /* |
cff9c4101dd7
Replaced old utils with ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
2 | * |
cff9c4101dd7
Replaced old utils with ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
3 | */ |
cff9c4101dd7
Replaced old utils with ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
4 | |
cff9c4101dd7
Replaced old utils with ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
5 | #ifndef MPOOL_H |
cff9c4101dd7
Replaced old utils with ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
6 | #define MPOOL_H |
cff9c4101dd7
Replaced old utils with ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
7 | |
36
450d2d5f4735
server can reload configuration
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
8 | #include <stddef.h> |
450d2d5f4735
server can reload configuration
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
9 | #include "allocator.h" |
450d2d5f4735
server can reload configuration
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
10 | |
15
cff9c4101dd7
Replaced old utils with ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
11 | #ifdef __cplusplus |
cff9c4101dd7
Replaced old utils with ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
12 | extern "C" { |
cff9c4101dd7
Replaced old utils with ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
13 | #endif |
cff9c4101dd7
Replaced old utils with ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
14 | |
cff9c4101dd7
Replaced old utils with ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
15 | typedef void(*ucx_destructor)(void*); |
cff9c4101dd7
Replaced old utils with ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
16 | |
cff9c4101dd7
Replaced old utils with ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
17 | typedef struct { |
cff9c4101dd7
Replaced old utils with ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
18 | void **data; |
cff9c4101dd7
Replaced old utils with ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
19 | size_t ndata; |
cff9c4101dd7
Replaced old utils with ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
20 | size_t size; |
cff9c4101dd7
Replaced old utils with ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
21 | } UcxMempool; |
cff9c4101dd7
Replaced old utils with ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
22 | |
36
450d2d5f4735
server can reload configuration
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
23 | #define UCX_ALLOCATOR_MEMPOOL(pool) {pool, \ |
450d2d5f4735
server can reload configuration
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
24 | (ucx_allocator_malloc) ucx_mempool_malloc, \ |
450d2d5f4735
server can reload configuration
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
25 | (ucx_allocator_calloc) ucx_mempool_calloc, \ |
450d2d5f4735
server can reload configuration
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
26 | (ucx_allocator_realloc) ucx_mempool_realloc} |
450d2d5f4735
server can reload configuration
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
15
diff
changeset
|
27 | |
15
cff9c4101dd7
Replaced old utils with ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
28 | #define ucx_mempool_new_default() ucx_mempool_new(16) |
cff9c4101dd7
Replaced old utils with ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
29 | UcxMempool *ucx_mempool_new(size_t n); |
cff9c4101dd7
Replaced old utils with ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
30 | int ucx_mempool_chcap(UcxMempool *pool, size_t newcap); |
cff9c4101dd7
Replaced old utils with ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
31 | |
cff9c4101dd7
Replaced old utils with ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
32 | void *ucx_mempool_malloc(UcxMempool *pool, size_t n); |
cff9c4101dd7
Replaced old utils with ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
33 | void *ucx_mempool_calloc(UcxMempool *pool, size_t nelem, size_t elsize); |
cff9c4101dd7
Replaced old utils with ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
34 | void *ucx_mempool_realloc(UcxMempool *pool, void *ptr, size_t n); |
cff9c4101dd7
Replaced old utils with ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
35 | |
cff9c4101dd7
Replaced old utils with ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
36 | void ucx_mempool_free(UcxMempool *pool); |
cff9c4101dd7
Replaced old utils with ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
37 | |
cff9c4101dd7
Replaced old utils with ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
38 | void ucx_mempool_set_destr(void *ptr, ucx_destructor func); |
cff9c4101dd7
Replaced old utils with ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
39 | void ucx_mempool_reg_destr(UcxMempool *pool, void *ptr, ucx_destructor destr); |
cff9c4101dd7
Replaced old utils with ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
40 | |
cff9c4101dd7
Replaced old utils with ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
41 | |
cff9c4101dd7
Replaced old utils with ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
42 | #ifdef __cplusplus |
cff9c4101dd7
Replaced old utils with ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
43 | } |
cff9c4101dd7
Replaced old utils with ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
44 | #endif |
cff9c4101dd7
Replaced old utils with ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
45 | |
cff9c4101dd7
Replaced old utils with ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
46 | #endif /* MPOOL_H */ |
cff9c4101dd7
Replaced old utils with ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
47 |