PJ_DEF(pj_hash_table_t*) pj_hash_create(pj_pool_t *pool, unsigned size) { pj_hash_table_t *h; unsigned table_size; /* Check that PJ_HASH_ENTRY_BUF_SIZE is correct. */ PJ_ASSERT_RETURN(sizeof(pj_hash_entry)<=PJ_HASH_ENTRY_BUF_SIZE, NULL); h = PJ_POOL_ALLOC_T(pool, pj_hash_table_t); h->count = 0; PJ_LOG( 6, ("hashtbl", "hash table %p created from pool %s", h, pj_pool_getobjname(pool))); /* size must be 2^n - 1. round-up the size to this rule, except when size is 2^n, then size will be round-down to 2^n-1. */ table_size = 8; do { table_size <<= 1; } while (table_size < size); table_size -= 1; h->rows = table_size; h->table = (pj_hash_entry**) pj_pool_calloc(pool, table_size+1, sizeof(pj_hash_entry*)); return h; }
static void cpool_dump_status(pj_pool_factory *factory, pj_bool_t detail ) { #if PJ_LOG_MAX_LEVEL >= 3 pj_caching_pool *cp = (pj_caching_pool*)factory; pj_lock_acquire(cp->lock); PJ_LOG(3,("cachpool", " Dumping caching pool:")); PJ_LOG(3,("cachpool", " Capacity=%u, max_capacity=%u, used_cnt=%u", \ cp->capacity, cp->max_capacity, cp->used_count)); if (detail) { pj_pool_t *pool = (pj_pool_t*) cp->used_list.next; pj_uint32_t total_used = 0, total_capacity = 0; PJ_LOG(3,("cachpool", " Dumping all active pools:")); while (pool != (void*)&cp->used_list) { unsigned pool_capacity = pj_pool_get_capacity(pool); PJ_LOG(3,("cachpool", " %12s: %8d of %8d (%d%%) used", pj_pool_getobjname(pool), pj_pool_get_used_size(pool), pool_capacity, pj_pool_get_used_size(pool)*100/pool_capacity)); total_used += pj_pool_get_used_size(pool); total_capacity += pool_capacity; pool = pool->next; } if (total_capacity) { PJ_LOG(3,("cachpool", " Total %9d of %9d (%d %%) used!", total_used, total_capacity, total_used * 100 / total_capacity)); } } pj_lock_release(cp->lock); #else PJ_UNUSED_ARG(factory); PJ_UNUSED_ARG(detail); #endif }
// // Get name. // const char *getobjname() const { return pj_pool_getobjname(p_); }