Ignore:
Timestamp:
Nov 21, 2005 4:58:03 PM (19 years ago)
Author:
bennylp
Message:

Small optimization in pool (removed used_size)

File:
1 edited

Legend:

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

    r66 r69  
    4646 
    4747    LOG((pool->obj_name, "create_block(sz=%u), cur.cap=%u, cur.used=%u",  
    48          size, pool->capacity, pool->used_size)); 
     48         size, pool->capacity, pj_pool_get_used_size(pool))); 
    4949 
    5050    /* Request memory from allocator. */ 
     
    5858    /* Add capacity. */ 
    5959    pool->capacity += size; 
    60     pool->used_size += sizeof(pj_pool_block); 
    6160 
    6261    /* Set block attribytes. */ 
     
    8786 
    8887    while (block != &pool->block_list) { 
    89         p = pj_pool_alloc_from_block(pool, block, size); 
     88        p = pj_pool_alloc_from_block(block, size); 
    9089        if (p != NULL) 
    9190            return p; 
     
    9897        LOG((pool->obj_name, "Can't expand pool to allocate %u bytes " 
    9998             "(used=%u, cap=%u)", 
    100              size, pool->used_size, pool->capacity)); 
     99             size, pj_pool_get_used_size(pool), pool->capacity)); 
    101100        (*pool->callback)(pool, size); 
    102101        return NULL; 
     
    119118    LOG((pool->obj_name,  
    120119         "%u bytes requested, resizing pool by %u bytes (used=%u, cap=%u)", 
    121          size, block_size, pool->used_size, pool->capacity)); 
     120         size, block_size, pj_pool_get_used_size(pool), pool->capacity)); 
    122121 
    123122    block = pj_pool_create_block(pool, block_size); 
     
    125124        return NULL; 
    126125 
    127     p = pj_pool_alloc_from_block(pool, block, size); 
     126    p = pj_pool_alloc_from_block(block, size); 
    128127    pj_assert(p != NULL); 
    129128#if PJ_DEBUG 
     
    143142                                pj_pool_callback *callback) 
    144143{ 
    145     pj_pool_block *block; 
    146  
    147144    PJ_CHECK_STACK(); 
    148145 
    149146    pool->increment_size = increment_size; 
    150147    pool->callback = callback; 
    151     pool->used_size = sizeof(*pool); 
    152     block = pool->block_list.next; 
    153     while (block != &pool->block_list) { 
    154         pool->used_size += sizeof(pj_pool_block); 
    155         block = block->next; 
    156     } 
    157148 
    158149    if (name) { 
     
    238229    block->cur = block->buf; 
    239230    pool->capacity = block->end - (unsigned char*)pool; 
    240     pool->used_size = 0; 
    241231} 
    242232 
     
    247237{ 
    248238    LOG((pool->obj_name, "reset(): cap=%d, used=%d(%d%%)",  
    249         pool->capacity, pool->used_size, pool->used_size*100/pool->capacity)); 
     239        pool->capacity, pj_pool_get_used_size(pool),  
     240        pj_pool_get_used_size(pool)*100/pool->capacity)); 
    250241 
    251242    reset_pool(pool); 
     
    260251 
    261252    LOG((pool->obj_name, "destroy(): cap=%d, used=%d(%d%%), block0=%p-%p",  
    262         pool->capacity, pool->used_size, pool->used_size*100/pool->capacity, 
     253        pool->capacity, pj_pool_get_used_size(pool),  
     254        pj_pool_get_used_size(pool)*100/pool->capacity, 
    263255        ((pj_pool_block*)pool->block_list.next)->buf,  
    264256        ((pj_pool_block*)pool->block_list.next)->end)); 
Note: See TracChangeset for help on using the changeset viewer.