- Timestamp:
- Jun 1, 2007 7:26:21 AM (17 years ago)
- Location:
- pjproject/trunk/pjlib
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/include/pj/config.h
r1246 r1333 389 389 390 390 /** 391 * Set this flag to non-zero to enable various checking for pool 392 * operations. When this flag is set, assertion must be enabled 393 * in the application. 394 * 395 * This will slow down pool creation and destruction and will add 396 * few bytes of overhead, so application would normally want to 397 * disable this feature on release build. 398 * 399 * Default: 0 400 */ 401 #ifndef PJ_SAFE_POOL 402 # define PJ_SAFE_POOL 0 403 #endif 404 405 406 /** 391 407 * If pool debugging is used, then each memory allocation from the pool 392 408 * will call malloc(), and pool will release all memory chunks when it -
pjproject/trunk/pjlib/src/pj/pool_caching.c
r1235 r1333 100 100 pj_pool_t *next = pool->next; 101 101 pj_list_erase(pool); 102 PJ_LOG(4,(pool->obj_name, 103 "Pool is not released by application, releasing now")); 102 104 pj_pool_destroy_int(pool); 103 105 pool = next; … … 198 200 PJ_CHECK_STACK(); 199 201 202 PJ_ASSERT_ON_FAIL(pf && pool, return); 203 200 204 pj_lock_acquire(cp->lock); 205 206 #if PJ_SAFE_POOL 207 /* Make sure pool is still in our used list */ 208 if (pj_list_find_node(&cp->used_list, pool) != pool) { 209 pj_assert(!"Attempt to destroy pool that has been destroyed before"); 210 return; 211 } 212 #endif 201 213 202 214 /* Erase from the used list. */ -
pjproject/trunk/pjlib/src/pj/pool_policy_malloc.c
r974 r1333 27 27 * This file contains pool default policy definition and implementation. 28 28 */ 29 #include "pool_signature.h" 29 30 30 31 … … 42 43 } 43 44 44 p = malloc(size );45 p = malloc(size+(SIG_SIZE << 1)); 45 46 46 47 if (p == NULL) { 47 48 if (factory->on_block_free) 48 49 factory->on_block_free(factory, size); 50 } else { 51 /* Apply signature when PJ_SAFE_POOL is set. It will move 52 * "p" pointer forward. 53 */ 54 APPLY_SIG(p, size); 49 55 } 50 56 … … 59 65 if (factory->on_block_free) 60 66 factory->on_block_free(factory, size); 67 68 /* Check and remove signature when PJ_SAFE_POOL is set. It will 69 * move "mem" pointer backward. 70 */ 71 REMOVE_SIG(mem, size); 72 73 /* Note that when PJ_SAFE_POOL is set, the actual size of the block 74 * is size + SIG_SIZE*2. 75 */ 61 76 62 77 free(mem); -
pjproject/trunk/pjlib/src/pj/pool_policy_new.cpp
r1235 r1333 26 26 * This file contains pool default policy definition and implementation. 27 27 */ 28 #include "pool_signature.h" 28 29 29 30 30 31 static void *operator_new(pj_pool_factory *factory, pj_size_t size) 31 32 { 33 void *mem; 34 32 35 PJ_CHECK_STACK(); 33 36 PJ_UNUSED_ARG(factory); 34 37 PJ_UNUSED_ARG(size); 35 38 36 return new char[size]; 39 mem = (void*) new char[size+(SIG_SIZE << 1)]; 40 41 /* Exception for new operator may be disabled, so.. */ 42 if (mem) { 43 /* Apply signature when PJ_SAFE_POOL is set. It will move 44 * "mem" pointer forward. 45 */ 46 APPLY_SIG(mem, size); 47 } 48 49 return mem; 37 50 } 38 51 … … 42 55 PJ_UNUSED_ARG(factory); 43 56 PJ_UNUSED_ARG(size); 57 58 /* Check and remove signature when PJ_SAFE_POOL is set. It will 59 * move "mem" pointer backward. 60 */ 61 REMOVE_SIG(mem, size); 62 63 /* Note that when PJ_SAFE_POOL is set, the actual size of the block 64 * is size + SIG_SIZE*2. 65 */ 44 66 45 67 char *p = (char*)mem;
Note: See TracChangeset
for help on using the changeset viewer.