| 37 #define UCX_MEMPOOL_H |
37 #define UCX_MEMPOOL_H |
| 38 |
38 |
| 39 #include "common.h" |
39 #include "common.h" |
| 40 #include "allocator.h" |
40 #include "allocator.h" |
| 41 |
41 |
| 42 /** A memory block in a simple memory pool. */ |
|
| 43 struct cx_mempool_memory_s { |
|
| 44 /** The destructor. */ |
|
| 45 cx_destructor_func destructor; |
|
| 46 /** The actual memory. */ |
|
| 47 char c[]; |
|
| 48 }; |
|
| 49 |
|
| 50 /** A memory block in an advanced memory pool. */ |
|
| 51 struct cx_mempool_memory2_s { |
|
| 52 /** The destructor. */ |
|
| 53 cx_destructor_func2 destructor; |
|
| 54 /** Data for the destructor. */ |
|
| 55 void *data; |
|
| 56 /** The actual memory. */ |
|
| 57 char c[]; |
|
| 58 }; |
|
| 59 |
|
| 60 /** Represents memory that is not allocated by, but registered with a pool. */ |
|
| 61 struct cx_mempool_foreign_memory_s { |
|
| 62 /** The foreign memory. */ |
|
| 63 void* mem; |
|
| 64 union { |
|
| 65 /** Simple destructor. */ |
|
| 66 cx_destructor_func destr; |
|
| 67 /** Advanced destructor. */ |
|
| 68 cx_destructor_func2 destr2; |
|
| 69 }; |
|
| 70 /** Data for the advanced destructor. */ |
|
| 71 void *destr2_data; |
|
| 72 }; |
|
| 73 |
|
| 74 /** Specifies how individual blocks are allocated. */ |
42 /** Specifies how individual blocks are allocated. */ |
| 75 enum cx_mempool_type { |
43 enum cx_mempool_type { |
| 76 /** |
44 /** |
| 77 * Allows registration of cx_destructor_func for each memory block. |
45 * Allows registration of cx_destructor_func for each memory block. |
| 78 */ |
46 */ |