libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit dbc57ff2f07ebed0755d4803a5bb5d192b64822a
parent 61456e4b13291054afcf420952e2ca4c14783894
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sun, 31 Mar 2013 17:02:07 +0000

-formatting

Diffstat:
Msrc/daemon/memorypool.c | 11++++++++++-
Msrc/daemon/memorypool.h | 32+++++++++++++++++++++-----------
2 files changed, 31 insertions(+), 12 deletions(-)

diff --git a/src/daemon/memorypool.c b/src/daemon/memorypool.c @@ -42,6 +42,11 @@ */ #define ROUND_TO_ALIGN(n) ((n+(ALIGN_SIZE-1)) & (~(ALIGN_SIZE-1))) + +/** + * Handle for a memory pool. Pools are not reentrant and must not be + * used by multiple threads. + */ struct MemoryPool { @@ -71,6 +76,7 @@ struct MemoryPool int is_mmap; }; + /** * Create a memory pool. * @@ -110,6 +116,7 @@ MHD_pool_create (size_t max) return pool; } + /** * Destroy a memory pool. */ @@ -125,6 +132,7 @@ MHD_pool_destroy (struct MemoryPool *pool) free (pool); } + /** * Allocate size bytes from the pool. * @return NULL if the pool cannot support size more @@ -152,6 +160,7 @@ MHD_pool_allocate (struct MemoryPool *pool, return ret; } + /** * Reallocate a block of memory obtained from the pool. * This is particularly efficient when growing or @@ -209,6 +218,7 @@ MHD_pool_reallocate (struct MemoryPool *pool, return NULL; } + /** * Clear all entries from the memory pool except * for "keep" of the given "size". @@ -237,5 +247,4 @@ MHD_pool_reset (struct MemoryPool *pool, } - /* end of memorypool.c */ diff --git a/src/daemon/memorypool.h b/src/daemon/memorypool.h @@ -37,17 +37,22 @@ */ struct MemoryPool; + /** * Create a memory pool. * * @param max maximum size of the pool */ -struct MemoryPool *MHD_pool_create (size_t max); +struct MemoryPool * +MHD_pool_create (size_t max); + /** * Destroy a memory pool. */ -void MHD_pool_destroy (struct MemoryPool *pool); +void +MHD_pool_destroy (struct MemoryPool *pool); + /** * Allocate size bytes from the pool. @@ -58,8 +63,10 @@ void MHD_pool_destroy (struct MemoryPool *pool); * @return NULL if the pool cannot support size more * bytes */ -void *MHD_pool_allocate (struct MemoryPool *pool, - size_t size, int from_end); +void * +MHD_pool_allocate (struct MemoryPool *pool, + size_t size, int from_end); + /** * Reallocate a block of memory obtained from the pool. @@ -77,10 +84,12 @@ void *MHD_pool_allocate (struct MemoryPool *pool, * NULL if the pool cannot support new_size * bytes (old continues to be valid for old_size) */ -void *MHD_pool_reallocate (struct MemoryPool *pool, - void *old, - size_t old_size, - size_t new_size); +void * +MHD_pool_reallocate (struct MemoryPool *pool, + void *old, + size_t old_size, + size_t new_size); + /** * Clear all entries from the memory pool except @@ -90,8 +99,9 @@ void *MHD_pool_reallocate (struct MemoryPool *pool, * @param size how many bytes need to be kept at this address * @return addr new address of "keep" (if it had to change) */ -void *MHD_pool_reset (struct MemoryPool *pool, - void *keep, - size_t size); +void * +MHD_pool_reset (struct MemoryPool *pool, + void *keep, + size_t size); #endif