mempool.h File Reference

Headers for mempool.c. More...

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_tmp_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)


Detailed Description

Headers for mempool.c.


Typedef Documentation

typedef struct mp_pool_t mp_pool_t

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.


Function Documentation

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  ) 

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  ) 


Generated on Tue May 25 00:30:44 2010 for tor by  doxygen 1.5.6