Ignore:
Timestamp:
Jan 29, 2010 10:10:49 AM (14 years ago)
Author:
bennylp
Message:

Fixed ticket #1037: Memory pool alignment error when alignment is set to be greater than the default (thanks John Ridges for the report):

  • fixed the pool allocation routines in PJLIB,
  • add alignment test in pjlib-test (only useful if PJ_POOL_ALIGNMENT is configured in config_site.h),
  • fixed other pool tests in pjlib-test which are broken when PJ_POOL_ALIGNMENT is enlarged
File:
1 edited

Legend:

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

    r2963 r3081  
    213213    /* Create the first block from the memory. */ 
    214214    block = (pj_pool_block*) (buffer + sizeof(*pool)); 
    215     block->cur = block->buf = ((unsigned char*)block) + sizeof(pj_pool_block); 
     215    block->buf = ((unsigned char*)block) + sizeof(pj_pool_block); 
    216216    block->end = buffer + initial_size; 
     217 
     218    /* Set the start pointer, aligning it as needed */ 
     219    block->cur = (unsigned char*) 
     220                 (((unsigned long)block->buf + PJ_POOL_ALIGNMENT - 1) & 
     221                  ~(PJ_POOL_ALIGNMENT - 1)); 
     222 
    217223    pj_list_insert_after(&pool->block_list, block); 
    218224 
     
    255261 
    256262    block = pool->block_list.next; 
    257     block->cur = block->buf; 
     263 
     264    /* Set the start pointer, aligning it as needed */ 
     265    block->cur = (unsigned char*) 
     266                 (((unsigned long)block->buf + PJ_POOL_ALIGNMENT - 1) & 
     267                  ~(PJ_POOL_ALIGNMENT - 1)); 
     268 
    258269    pool->capacity = block->end - (unsigned char*)pool; 
    259270} 
Note: See TracChangeset for help on using the changeset viewer.