src/microhttpd/memorypool.h File Reference

memory pool; mostly used for efficient (de)allocation for each connection and bounding memory use for each request More...

#include "internal.h"
Include dependency graph for memorypool.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

struct MemoryPool * MHD_pool_create (size_t max)
void MHD_pool_destroy (struct MemoryPool *pool)
void * MHD_pool_allocate (struct MemoryPool *pool, size_t size, int from_end)
void * MHD_pool_reallocate (struct MemoryPool *pool, void *old, size_t old_size, size_t new_size)
void * MHD_pool_reset (struct MemoryPool *pool, void *keep, size_t size)

Detailed Description

memory pool; mostly used for efficient (de)allocation for each connection and bounding memory use for each request

Author:
Christian Grothoff

Definition in file memorypool.h.


Function Documentation

void* MHD_pool_allocate ( struct MemoryPool *  pool,
size_t  size,
int  from_end 
)

Allocate size bytes from the pool.

Parameters:
pool memory pool to use for the operation
size number of bytes to allocate
from_end allocate from end of pool (set to MHD_YES); use this for small, persistent allocations that will never be reallocated
Returns:
NULL if the pool cannot support size more bytes

Allocate size bytes from the pool.

Parameters:
pool memory pool to use for the operation
size number of bytes to allocate
from_end allocate from end of pool (set to MHD_YES); use this for small, persistent allocations that will never be reallocated
Returns:
NULL if the pool cannot support size more bytes

Definition at line 154 of file memorypool.c.

References MHD_YES, NULL, and ROUND_TO_ALIGN.

Referenced by build_header_response(), MHD_set_connection_value(), parse_cookie_header(), and try_ready_chunked_body().

Here is the caller graph for this function:

struct MemoryPool* MHD_pool_create ( size_t  max  )  [read]

Create a memory pool.

Parameters:
max maximum size of the pool
Returns:
NULL on error

Definition at line 87 of file memorypool.c.

References MAP_FAILED, MHD_NO, MHD_YES, and NULL.

Referenced by internal_add_connection().

Here is the caller graph for this function:

void MHD_pool_destroy ( struct MemoryPool *  pool  ) 

Destroy a memory pool.

Parameters:
pool memory pool to destroy

Definition at line 130 of file memorypool.c.

References MHD_NO, and NULL.

Referenced by internal_add_connection(), MHD_cleanup_connections(), and MHD_connection_handle_idle().

Here is the caller graph for this function:

void* MHD_pool_reallocate ( struct MemoryPool *  pool,
void *  old,
size_t  old_size,
size_t  new_size 
)

Reallocate a block of memory obtained from the pool. This is particularly efficient when growing or shrinking the block that was last (re)allocated. If the given block is not the most recenlty (re)allocated block, the memory of the previous allocation may be leaked until the pool is destroyed (and copying the data maybe required).

Parameters:
pool memory pool to use for the operation
old the existing block
old_size the size of the existing block
new_size the new size of the block
Returns:
new address of the block, or NULL if the pool cannot support new_size bytes (old continues to be valid for old_size)

Reallocate a block of memory obtained from the pool. This is particularly efficient when growing or shrinking the block that was last (re)allocated. If the given block is not the most recenlty (re)allocated block, the memory of the previous allocation may be leaked until the pool is destroyed (and copying the data maybe required).

Parameters:
pool memory pool to use for the operation
old the existing block
old_size the size of the existing block
new_size the new size of the block
Returns:
new address of the block, or NULL if the pool cannot support new_size bytes (old continues to be valid for old_size)

Definition at line 197 of file memorypool.c.

References NULL, and ROUND_TO_ALIGN.

Referenced by check_write_done(), MHD_connection_handle_read(), process_broken_line(), and try_grow_read_buffer().

Here is the caller graph for this function:

void* MHD_pool_reset ( struct MemoryPool *  pool,
void *  keep,
size_t  size 
)

Clear all entries from the memory pool except for "keep" of the given "size".

Parameters:
pool memory pool to use for the operation
keep pointer to the entry to keep (maybe NULL)
size how many bytes need to be kept at this address
Returns:
addr new address of "keep" (if it had to change)

Clear all entries from the memory pool except for keep of the given size.

Parameters:
pool memory pool to use for the operation
keep pointer to the entry to keep (maybe NULL)
size how many bytes need to be kept at this address
Returns:
addr new address of keep (if it had to change)

Definition at line 251 of file memorypool.c.

References NULL, and ROUND_TO_ALIGN.

Referenced by MHD_connection_handle_idle().

Here is the caller graph for this function:


Generated on 17 Oct 2014 for GNU libmicrohttpd by  doxygen 1.6.1