diff options
author | Andrea Shepard <andrea@torproject.org> | 2014-05-21 10:53:25 -0700 |
---|---|---|
committer | Andrea Shepard <andrea@torproject.org> | 2014-05-21 10:53:25 -0700 |
commit | 170e0df7417e78f7b689f3189e7a0b5b8dfd2722 (patch) | |
tree | ca9a54f3bf8fe4af2970f8f4d6ec8cb1124b64ac /src/or | |
parent | b3edd0406541d427a12c4e34d9380573929d0182 (diff) | |
download | tor-170e0df7417e78f7b689f3189e7a0b5b8dfd2722.tar tor-170e0df7417e78f7b689f3189e7a0b5b8dfd2722.tar.gz |
Eliminate #ifdef ENABLE_MEMPOOLS in packed_cell_new/free()
Diffstat (limited to 'src/or')
-rw-r--r-- | src/or/relay.c | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/src/or/relay.c b/src/or/relay.c index e593f87fc..5c430a6d7 100644 --- a/src/or/relay.c +++ b/src/or/relay.c @@ -2268,6 +2268,22 @@ clean_cell_pool(void) mp_pool_clean(cell_pool, 0, 1); } +#define relay_alloc_cell() \ + mp_pool_get(cell_pool) +#define relay_free_cell(cell) \ + mp_pool_release(cell) + +#define RELAY_CELL_MEM_COST (sizeof(packed_cell_t) + MP_POOL_ITEM_OVERHEAD) + +#else /* !ENABLE_MEMPOOLS case */ + +#define relay_alloc_cell() \ + tor_malloc_zero(sizeof(packed_cell_t)) +#define relay_free_cell(cell) \ + tor_free(cell) + +#define RELAY_CELL_MEM_COST (sizeof(packed_cell_t)) + #endif /* ENABLE_MEMPOOLS */ /** Release storage held by <b>cell</b>. */ @@ -2275,11 +2291,7 @@ static INLINE void packed_cell_free_unchecked(packed_cell_t *cell) { --total_cells_allocated; -#ifdef ENABLE_MEMPOOLS - mp_pool_release(cell); -#else - tor_free(cell); -#endif /* ENABLE_MEMPOOLS */ + relay_free_cell(cell); } /** Allocate and return a new packed_cell_t. */ @@ -2287,11 +2299,7 @@ STATIC packed_cell_t * packed_cell_new(void) { ++total_cells_allocated; -#ifdef ENABLE_MEMPOOLS - return mp_pool_get(cell_pool); -#else - return tor_malloc(sizeof(packed_cell_t)); -#endif + return relay_alloc_cell(); } /** Return a packed cell used outside by channel_t lower layer */ @@ -2402,11 +2410,7 @@ cell_queue_pop(cell_queue_t *queue) size_t packed_cell_mem_cost(void) { -#ifdef ENABLE_MEMPOOLS - return sizeof(packed_cell_t) + MP_POOL_ITEM_OVERHEAD; -#else - return sizeof(packed_cell_t); -#endif /* ENABLE_MEMPOOLS */ + return RELAY_CELL_MEM_COST; } /** DOCDOC */ |