Ignore:
Timestamp:
Jan 29, 2010 11:20:43 AM (14 years ago)
Author:
bennylp
Message:

More ticket #1037:

  • bug in aligning pointer if sizeof(long) is less than sizeof(void*). Thanks John Ridges for pointing this out
File:
1 edited

Legend:

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

    r3081 r3082  
    3232#endif 
    3333 
    34 #define LOG(expr)   PJ_LOG(6,expr) 
     34#define LOG(expr)                       PJ_LOG(6,expr) 
     35#define ALIGN_PTR(PTR,ALIGNMENT)        (PTR + (-(long)(PTR) & (ALIGNMENT-1))) 
    3536 
    3637PJ_DEF_DATA(int) PJ_NO_MEMORY_EXCEPTION; 
     
    7273 
    7374    /* Set the start pointer, aligning it as needed */ 
    74     block->cur = (unsigned char*) 
    75                  (((unsigned long)block->buf + PJ_POOL_ALIGNMENT - 1) &  
    76                   ~(PJ_POOL_ALIGNMENT - 1)); 
     75    block->cur = ALIGN_PTR(block->buf, PJ_POOL_ALIGNMENT); 
    7776 
    7877    /* Insert in the front of the list. */ 
     
    217216 
    218217    /* 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)); 
     218    block->cur = ALIGN_PTR(block->buf, PJ_POOL_ALIGNMENT); 
    222219 
    223220    pj_list_insert_after(&pool->block_list, block); 
     
    263260 
    264261    /* 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)); 
     262    block->cur = ALIGN_PTR(block->buf, PJ_POOL_ALIGNMENT); 
    268263 
    269264    pool->capacity = block->end - (unsigned char*)pool; 
Note: See TracChangeset for help on using the changeset viewer.