gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libmicrohttpd] 01/04: memory pool: added internal helper function


From: gnunet
Subject: [libmicrohttpd] 01/04: memory pool: added internal helper function
Date: Mon, 23 Aug 2021 21:27:18 +0200

This is an automated email from the git hooks/post-receive script.

karlson2k pushed a commit to branch master
in repository libmicrohttpd.

commit 5c8b5aefd0c3859fb830a64512f318bac4c745b5
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Mon Aug 23 22:13:00 2021 +0300

    memory pool: added internal helper function
---
 src/microhttpd/memorypool.c | 16 ++++++++++++++++
 src/microhttpd/memorypool.h | 13 +++++++++++++
 2 files changed, 29 insertions(+)

diff --git a/src/microhttpd/memorypool.c b/src/microhttpd/memorypool.c
index d2a0f197..adda0e98 100644
--- a/src/microhttpd/memorypool.c
+++ b/src/microhttpd/memorypool.c
@@ -102,6 +102,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
index 2d1fd119..11355a87 100644
--- a/src/microhttpd/memorypool.h
+++ b/src/microhttpd/memorypool.h
@@ -50,6 +50,19 @@ void
 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.
  *

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]