Changeset 69 for pjproject/trunk/pjlib/include/pj/pool_i.h
- Timestamp:
- Nov 21, 2005 4:58:03 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/include/pj/pool_i.h
r66 r69 30 30 PJ_IDEF(pj_size_t) pj_pool_get_used_size( pj_pool_t *pool ) 31 31 { 32 return pool->used_size; 32 pj_pool_block *b = pool->block_list.next; 33 pj_size_t used_size = sizeof(pj_pool_t); 34 while (b != &pool->block_list) { 35 used_size += (b->cur - b->buf) + sizeof(pj_pool_block); 36 b = b->next; 37 } 38 return used_size; 33 39 } 34 40 35 PJ_IDEF(void*) pj_pool_alloc_from_block( pj_pool_t *pool, 36 pj_pool_block *block, pj_size_t size ) 41 PJ_IDEF(void*) pj_pool_alloc_from_block( pj_pool_block *block, pj_size_t size ) 37 42 { 38 43 /* The operation below is valid for size==0. … … 41 46 */ 42 47 if (size & (PJ_POOL_ALIGNMENT-1)) { 43 size &= ~(PJ_POOL_ALIGNMENT-1); 44 size += PJ_POOL_ALIGNMENT; 48 size = (size + PJ_POOL_ALIGNMENT) & ~(PJ_POOL_ALIGNMENT-1); 45 49 } 46 50 if ((unsigned)(block->end - block->cur) >= size) { 47 51 void *ptr = block->cur; 48 52 block->cur += size; 49 pool->used_size += size;50 53 return ptr; 51 54 } … … 55 58 PJ_IDEF(void*) pj_pool_alloc( pj_pool_t *pool, pj_size_t size) 56 59 { 57 pj_pool_block *block = pool->block_list.next; 58 void *ptr = pj_pool_alloc_from_block(pool, block, size); 60 void *ptr = pj_pool_alloc_from_block(pool->block_list.next, size); 59 61 if (!ptr) 60 62 ptr = pj_pool_allocate_find(pool, size);
Note: See TracChangeset
for help on using the changeset viewer.