Go to the source code of this file.
Typedefs | |
| typedef struct mp_pool_t | mp_pool_t | 
Functions | |
| void * | mp_pool_get (mp_pool_t *pool) | 
| void | mp_pool_release (void *item) | 
| mp_pool_t * | mp_pool_new (size_t item_size, size_t chunk_capacity) | 
| void | mp_pool_clean (mp_pool_t *pool, int n_to_keep, int keep_recently_used) | 
| void | mp_pool_destroy (mp_pool_t *pool) | 
| void | mp_pool_assert_ok (mp_pool_t *pool) | 
| void | mp_pool_log_status (mp_pool_t *pool, int severity) | 
A memory pool is a context in which a large number of fixed-sized objects can be allocated efficiently. See mempool.c for implementation details.
| void mp_pool_assert_ok | ( | mp_pool_t * | pool | ) | 
Fail with an assertion if pool is not internally consistent.
| void mp_pool_clean | ( | mp_pool_t * | pool, | |
| int | n_to_keep, | |||
| int | keep_recently_used | |||
| ) | 
If there are more than n empty chunks in pool, free the excess ones that have been empty for the longest. If keep_recently_used is true, do not free chunks unless they have been empty since the last call to this function.
References mp_chunk_t::magic, and mp_chunk_t::next.
| void mp_pool_destroy | ( | mp_pool_t * | pool | ) | 
Free all space held in pool This makes all pointers returned from mp_pool_get(pool) invalid.
| void* mp_pool_get | ( | mp_pool_t * | pool | ) | 
Return a newly allocated item from pool.
References mp_chunk_t::capacity, mp_chunk_t::first_free, mp_allocated_t::in_chunk, mp_chunk_t::mem, mp_chunk_t::mem_size, mp_chunk_t::n_allocated, mp_chunk_t::next, mp_allocated_t::next_free, mp_chunk_t::next_mem, mp_chunk_t::prev, and mp_allocated_t::u.
| void mp_pool_log_status | ( | mp_pool_t * | pool, | |
| int | severity | |||
| ) | 
Dump information about pool's memory usage to the Tor log at level severity.
References LD_MM, mp_chunk_t::mem_size, mp_chunk_t::n_allocated, and mp_chunk_t::next.
| mp_pool_t* mp_pool_new | ( | size_t | item_size, | |
| size_t | chunk_capacity | |||
| ) | 
Allocate a new memory pool to hold items of size item_size. We'll try to fit about chunk_capacity bytes in each chunk.
References LD_MM, round_to_power_of_2(), STRUCT_OFFSET, and tor_assert.
| void mp_pool_release | ( | void * | item | ) | 
Return an allocated memory item to its memory pool.
References mp_chunk_t::capacity, mp_chunk_t::first_free, mp_allocated_t::in_chunk, mp_chunk_t::magic, mp_chunk_t::mem, mp_chunk_t::n_allocated, mp_chunk_t::next, mp_allocated_t::next_free, mp_chunk_t::next_mem, mp_chunk_t::pool, mp_chunk_t::prev, and mp_allocated_t::u.
 1.5.6