Wed, 21 Jan 2026 22:24:28 +0100
mempool.h - internalize structs that are not C++ compatible
relates to #799
| src/cx/mempool.h | file | annotate | diff | comparison | revisions | |
| src/mempool.c | file | annotate | diff | comparison | revisions |
--- a/src/cx/mempool.h Wed Jan 21 22:07:03 2026 +0100 +++ b/src/cx/mempool.h Wed Jan 21 22:24:28 2026 +0100 @@ -39,38 +39,6 @@ #include "common.h" #include "allocator.h" -/** A memory block in a simple memory pool. */ -struct cx_mempool_memory_s { - /** The destructor. */ - cx_destructor_func destructor; - /** The actual memory. */ - char c[]; -}; - -/** A memory block in an advanced memory pool. */ -struct cx_mempool_memory2_s { - /** The destructor. */ - cx_destructor_func2 destructor; - /** Data for the destructor. */ - void *data; - /** The actual memory. */ - char c[]; -}; - -/** Represents memory that is not allocated by, but registered with a pool. */ -struct cx_mempool_foreign_memory_s { - /** The foreign memory. */ - void* mem; - union { - /** Simple destructor. */ - cx_destructor_func destr; - /** Advanced destructor. */ - cx_destructor_func2 destr2; - }; - /** Data for the advanced destructor. */ - void *destr2_data; -}; - /** Specifies how individual blocks are allocated. */ enum cx_mempool_type { /**
--- a/src/mempool.c Wed Jan 21 22:07:03 2026 +0100 +++ b/src/mempool.c Wed Jan 21 22:24:28 2026 +0100 @@ -31,6 +31,38 @@ #include <string.h> #include <errno.h> +/** A memory block in a simple memory pool. */ +struct cx_mempool_memory_s { + /** The destructor. */ + cx_destructor_func destructor; + /** The actual memory. */ + char c[]; +}; + +/** A memory block in an advanced memory pool. */ +struct cx_mempool_memory2_s { + /** The destructor. */ + cx_destructor_func2 destructor; + /** Data for the destructor. */ + void *data; + /** The actual memory. */ + char c[]; +}; + +/** Represents memory that is not allocated by, but registered with a pool. */ +struct cx_mempool_foreign_memory_s { + /** The foreign memory. */ + void* mem; + union { + /** Simple destructor. */ + cx_destructor_func destr; + /** Advanced destructor. */ + cx_destructor_func2 destr2; + }; + /** Data for the advanced destructor. */ + void *destr2_data; +}; + static int cx_mempool_ensure_capacity( struct cx_mempool_s *pool, size_t needed_capacity