Changeset 588 for pjproject/trunk
- Timestamp:
- Jul 6, 2006 2:27:31 PM (18 years ago)
- Location:
- pjproject/trunk/pjlib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/include/pj/pool.h
r364 r588 157 157 /** Pool factory. */ 158 158 pj_pool_factory *factory; 159 160 /** Data put by factory */ 161 void *factory_data; 159 162 160 163 /** Current capacity allocated by the pool. */ -
pjproject/trunk/pjlib/src/pj/pool_caching.c
r582 r588 39 39 }; 40 40 41 /* Index where the search for size should begin. 42 * Start with pool_sizes[5], which is 8192. 43 */ 44 #define START_SIZE 5 45 41 46 42 47 PJ_DEF(void) pj_caching_pool_init( pj_caching_pool *cp, … … 119 124 * for this purpose. 120 125 */ 121 for (idx=0; 122 idx < PJ_CACHING_POOL_ARRAY_SIZE && pool_sizes[idx] < initial_size; 123 ++idx) 124 ; 126 if (initial_size <= pool_sizes[START_SIZE]) { 127 for (idx=START_SIZE-1; 128 idx >= 0 && pool_sizes[idx] >= initial_size; 129 --idx) 130 ; 131 ++idx; 132 } else { 133 for (idx=START_SIZE+1; 134 idx < PJ_CACHING_POOL_ARRAY_SIZE && 135 pool_sizes[idx] < initial_size; 136 ++idx) 137 ; 138 } 125 139 126 140 /* Check whether there's a pool in the list. */ … … 156 170 pj_list_insert_before( &cp->used_list, pool ); 157 171 172 /* Mark factory data */ 173 pool->factory_data = (void*) idx; 174 158 175 /* Increment used count. */ 159 176 ++cp->used_count; … … 167 184 pj_caching_pool *cp = (pj_caching_pool*)pf; 168 185 unsigned pool_capacity; 169 inti;186 unsigned i; 170 187 171 188 PJ_CHECK_STACK(); … … 204 221 * Otherwise put the pool in our recycle list. 205 222 */ 206 for (i=0; i < PJ_CACHING_POOL_ARRAY_SIZE && pool_sizes[i] != pool_capacity; ++i) 207 ; 208 209 pj_assert( i != PJ_CACHING_POOL_ARRAY_SIZE ); 210 if (i == PJ_CACHING_POOL_ARRAY_SIZE) { 223 i = (unsigned)pool->factory_data; 224 225 pj_assert(i<PJ_CACHING_POOL_ARRAY_SIZE); 226 if (i >= PJ_CACHING_POOL_ARRAY_SIZE ) { 211 227 /* Something has gone wrong with the pool. */ 212 228 pj_pool_destroy_int(pool);
Note: See TracChangeset
for help on using the changeset viewer.