commit 5c8b5aefd0c3859fb830a64512f318bac4c745b5 parent 11a2e0126e68fb6f70be1734f54ef9963d6a6352 Author: Evgeny Grin (Karlson2k) <k2k@narod.ru> Date: Mon, 23 Aug 2021 22:13:00 +0300 memory pool: added internal helper function Diffstat:
| M | src/microhttpd/memorypool.c | | | 16 | ++++++++++++++++ |
| M | src/microhttpd/memorypool.h | | | 13 | +++++++++++++ |
2 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/src/microhttpd/memorypool.c b/src/microhttpd/memorypool.c @@ -103,6 +103,22 @@ MHD_init_mem_pools_ (void) /** + * Get the real size that would be allocated by the memory pool when + * requested to allocate @a size. + * @param size the size of memory area that would be rounded up to the + * allocation granularity + * @return the size that would be allocated by #MHD_pool_allocate() when + * requested to allocate @a size. It is also minimal size of free + * space in the pool required to #MHD_pool_allocate() succeed. + */ +size_t +MHD_pool_alloc_size (size_t size) +{ + return ROUND_TO_ALIGN (size); +} + + +/** * Handle for a memory pool. Pools are not reentrant and must not be * used by multiple threads. */ diff --git a/src/microhttpd/memorypool.h b/src/microhttpd/memorypool.h @@ -51,6 +51,19 @@ MHD_init_mem_pools_ (void); /** + * Get the real size that would be allocated by the memory pool when + * requested to allocate @a size. + * @param size the size of memory area that would be rounded up to the + * allocation granularity + * @return the size that would be allocated by #MHD_pool_allocate() when + * requested to allocate @a size. It is also minimal size of free + * space in the pool required to #MHD_pool_allocate() succeed. + */ +size_t +MHD_pool_alloc_size (size_t size); + + +/** * Create a memory pool. * * @param max maximum size of the pool