Ignore:
Timestamp:
Mar 30, 2006 3:56:01 PM (19 years ago)
Author:
bennylp
Message:

Added ability to have custom pool backend (needed for pool debugging facility)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib/src/pj/pool_caching.c

    r338 r364  
    2323#include <pj/os.h> 
    2424 
     25#if !PJ_HAS_POOL_ALT_API 
     26 
    2527static pj_pool_t* cpool_create_pool(pj_pool_factory *pf,  
    2628                                    const char *name, 
     
    164166{ 
    165167    pj_caching_pool *cp = (pj_caching_pool*)pf; 
     168    unsigned pool_capacity; 
    166169    int i; 
    167170 
     
    175178    /* Decrement used count. */ 
    176179    --cp->used_count; 
     180 
     181    pool_capacity = pj_pool_get_capacity(pool); 
    177182 
    178183    /* Destroy the pool if the size is greater than our size or if the total 
     
    180185     * maximum capacity. 
    181186   . */ 
    182     if (pool->capacity > pool_sizes[PJ_CACHING_POOL_ARRAY_SIZE-1] || 
    183         cp->capacity + pool->capacity > cp->max_capacity) 
     187    if (pool_capacity > pool_sizes[PJ_CACHING_POOL_ARRAY_SIZE-1] || 
     188        cp->capacity + pool_capacity > cp->max_capacity) 
    184189    { 
    185190        pj_pool_destroy_int(pool); 
     
    190195    /* Reset pool. */ 
    191196    PJ_LOG(6, (pool->obj_name, "recycle(): cap=%d, used=%d(%d%%)",  
    192                pool->capacity, pj_pool_get_used_size(pool),  
    193                pj_pool_get_used_size(pool)*100/pool->capacity)); 
     197               pool_capacity, pj_pool_get_used_size(pool),  
     198               pj_pool_get_used_size(pool)*100/pool_capacity)); 
    194199    pj_pool_reset(pool); 
    195200 
     
    197202     * Otherwise put the pool in our recycle list. 
    198203     */ 
    199     for (i=0; i < PJ_CACHING_POOL_ARRAY_SIZE && pool_sizes[i] != pool->capacity; ++i) 
     204    for (i=0; i < PJ_CACHING_POOL_ARRAY_SIZE && pool_sizes[i] != pool_capacity; ++i) 
    200205        ; 
    201206 
     
    209214 
    210215    pj_list_insert_after(&cp->free_list[i], pool); 
    211     cp->capacity += pool->capacity; 
     216    cp->capacity += pool_capacity; 
    212217 
    213218    pj_mutex_unlock(cp->mutex); 
     
    229234        PJ_LOG(3,("cachpool", "  Dumping all active pools:")); 
    230235        while (pool != (void*)&cp->used_list) { 
    231             PJ_LOG(3,("cachpool", "   %12s: %8d of %8d (%d%%) used", pool->obj_name,  
    232                                   pj_pool_get_used_size(pool), pool->capacity, 
    233                                   pj_pool_get_used_size(pool)*100/pool->capacity)); 
     236            unsigned pool_capacity = pj_pool_get_capacity(pool); 
     237            PJ_LOG(3,("cachpool", "   %12s: %8d of %8d (%d%%) used",  
     238                                  pj_pool_getobjname(pool),  
     239                                  pj_pool_get_used_size(pool),  
     240                                  pool_capacity, 
     241                                  pj_pool_get_used_size(pool)*100/pool_capacity)); 
    234242            total_used += pj_pool_get_used_size(pool); 
    235             total_capacity += pool->capacity; 
     243            total_capacity += pool_capacity; 
    236244            pool = pool->next; 
    237245        } 
     
    247255#endif 
    248256} 
     257 
     258#endif  /* PJ_HAS_POOL_ALT_API */ 
     259 
Note: See TracChangeset for help on using the changeset viewer.