mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
r12338@catbus: nickm | 2007-04-10 20:29:05 -0400
Document memory pool implementation, and tweak it even mor. See? Programming is fun. svn:r9940
This commit is contained in:
+8
-6
@@ -1479,8 +1479,8 @@ circuit_consider_sending_sendme(circuit_t *circ, crypt_path_t *layer_hint)
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_CELL_POOL
|
||||
static mp_pool_t *cell_pool;
|
||||
/* DOCDOC */
|
||||
static mp_pool_t *cell_pool = NULL;
|
||||
/** Allocate structures to hold cells. */
|
||||
void
|
||||
init_cell_pool(void)
|
||||
{
|
||||
@@ -1488,7 +1488,7 @@ init_cell_pool(void)
|
||||
cell_pool = mp_pool_new(sizeof(packed_cell_t), 64);
|
||||
}
|
||||
|
||||
/* DOCDOC */
|
||||
/** Free all storage used to hold cells. */
|
||||
void
|
||||
free_cell_pool(void)
|
||||
{
|
||||
@@ -1497,20 +1497,22 @@ free_cell_pool(void)
|
||||
cell_pool = NULL;
|
||||
}
|
||||
|
||||
/** Release storage held by <b>cell</b> */
|
||||
/** Release storage held by <b>cell</b>. */
|
||||
static INLINE void
|
||||
packed_cell_free(packed_cell_t *cell)
|
||||
{
|
||||
mp_pool_release(cell);
|
||||
}
|
||||
|
||||
/* DOCDOC */
|
||||
static INLINE packed_cell_t*
|
||||
/** Allocate and return a new packed_cell_t. */
|
||||
static INLINE packed_cell_t *
|
||||
packed_cell_alloc(void)
|
||||
{
|
||||
return mp_pool_get(cell_pool);
|
||||
}
|
||||
#else
|
||||
/* ENABLE_CELL_POOL isn't defined: here are some stubs to use tor_malloc()
|
||||
* and tor_free() instead. */
|
||||
void
|
||||
init_cell_pool(void)
|
||||
{
|
||||
|
||||
+3
-1
@@ -2142,13 +2142,15 @@ test_mempool(void)
|
||||
//mp_pool_assert_ok(pool);
|
||||
}
|
||||
if (crypto_rand_int(777)==0)
|
||||
mp_pool_clean(pool);
|
||||
mp_pool_clean(pool, 2);
|
||||
|
||||
if (i % 777)
|
||||
mp_pool_assert_ok(pool);
|
||||
}
|
||||
SMARTLIST_FOREACH(allocated, void *, m, mp_pool_release(m));
|
||||
mp_pool_assert_ok(pool);
|
||||
mp_pool_clean(pool, 0);
|
||||
mp_pool_assert_ok(pool);
|
||||
mp_pool_destroy(pool);
|
||||
smartlist_free(allocated);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user