Changeset 1308


Ignore:
Timestamp:
May 28, 2007 12:01:51 PM (12 years ago)
Author:
bennylp
Message:

Fixed ticket #305: Memory alignment error for hash entry buffer causing crash on ARM (thanks ChenHuan?)

Location:
pjproject/branches/pjproject-0.5-stable
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/pjproject-0.5-stable/pjlib-util/src/pjlib-util/resolver.c

    r1277 r1308  
    126126 
    127127    struct res_key       key;           /**< Key to index this query.       */ 
    128     char                 hbufid[PJ_HASH_ENTRY_SIZE];    /**< Hash buffer 1  */ 
    129     char                 hbufkey[PJ_HASH_ENTRY_SIZE];   /**< Hash buffer 2  */ 
     128    pj_hash_entry_buf    hbufid;        /**< Hash buffer 1                  */ 
     129    pj_hash_entry_buf    hbufkey;       /**< Hash buffer 2                  */ 
    130130    pj_timer_entry       timer_entry;   /**< Timer to manage timeouts       */ 
    131131    unsigned             options;       /**< Query options.                 */ 
     
    145145    struct res_key           key;           /**< Resource key.              */ 
    146146    char                     buf[RES_BUF_SZ];/**< Resource buffer.          */ 
    147     char                     hbuf[PJ_HASH_ENTRY_SIZE];  /**< Hash buffer    */ 
     147    pj_hash_entry_buf        hbuf;          /**< Hash buffer                */ 
    148148    pj_time_val              expiry_time;   /**< Expiration time.           */ 
    149149    pj_dns_parsed_packet    *pkt;           /**< The response packet.       */ 
  • pjproject/branches/pjproject-0.5-stable/pjlib/include/pj/hash.h

    r974 r1308  
    4848 * This indicates the size of of each hash entry. 
    4949 */ 
    50 #define PJ_HASH_ENTRY_SIZE      (3*sizeof(void*) + 2*sizeof(pj_uint32_t)) 
     50#define PJ_HASH_ENTRY_BUF_SIZE  (3*sizeof(void*) + 2*sizeof(pj_uint32_t)) 
     51 
     52/** 
     53 * Type declaration for entry buffer, used by #pj_hash_set_np() 
     54 */ 
     55typedef void *pj_hash_entry_buf[(PJ_HASH_ENTRY_BUF_SIZE+sizeof(void*)-1)/(sizeof(void*))]; 
    5156 
    5257/** 
     
    148153 *                  compute the key. This value can be obtained when calling 
    149154 *                  #pj_hash_get(). 
    150  * @param entry_buf Pointer to buffer which will be used for the new entry, 
    151  *                  when one needs to be created. The buffer must be at least 
    152  *                  PJ_HASH_ENTRY_SIZE long, and the first PJ_HASH_ENTRY_SIZE 
    153  *                  bytes of the buffer will be used by the hash table. 
    154  *                  Application may use the remaining portion of the buffer 
    155  *                  for its own purpose. 
     155 * @param entry_buf Buffer which will be used for the new entry, when one needs 
     156 *                  to be created. 
    156157 * @param value     value to be associated, or NULL to delete the entry with 
    157158 *                  the specified key. 
     
    159160PJ_DECL(void) pj_hash_set_np(pj_hash_table_t *ht, 
    160161                             const void *key, unsigned keylen,  
    161                              pj_uint32_t hval, void *entry_buf, void *value); 
     162                             pj_uint32_t hval, pj_hash_entry_buf entry_buf,  
     163                             void *value); 
    162164 
    163165/** 
  • pjproject/branches/pjproject-0.5-stable/pjlib/src/pj/hash.c

    r1185 r1308  
    101101    unsigned table_size; 
    102102     
    103     /* Check that PJ_HASH_ENTRY_SIZE is correct. */ 
    104     PJ_ASSERT_RETURN(sizeof(pj_hash_entry)==PJ_HASH_ENTRY_SIZE, NULL); 
     103    /* Check that PJ_HASH_ENTRY_BUF_SIZE is correct. */ 
     104    PJ_ASSERT_RETURN(sizeof(pj_hash_entry)<=PJ_HASH_ENTRY_BUF_SIZE, NULL); 
    105105 
    106106    h = pj_pool_alloc(pool, sizeof(pj_hash_table_t)); 
     
    237237PJ_DEF(void) pj_hash_set_np( pj_hash_table_t *ht, 
    238238                             const void *key, unsigned keylen,  
    239                              pj_uint32_t hval, void *entry_buf, void *value) 
     239                             pj_uint32_t hval, pj_hash_entry_buf entry_buf,  
     240                             void *value) 
    240241{ 
    241242    pj_hash_entry **p_entry; 
    242243 
    243     p_entry = find_entry( NULL, ht, key, keylen, value, &hval, entry_buf ); 
     244    p_entry = find_entry( NULL, ht, key, keylen, value, &hval,  
     245                         (void*)entry_buf ); 
    244246    if (*p_entry) { 
    245247        if (value == NULL) { 
  • pjproject/branches/pjproject-0.5-stable/pjsip/src/pjsip/sip_ua_layer.c

    r988 r1308  
    6363 
    6464    /* This is the buffer to store this entry in the hash table. */ 
    65     char ht_entry[PJ_HASH_ENTRY_SIZE]; 
     65    pj_hash_entry_buf ht_entry; 
    6666 
    6767    /* List of dialog in this dialog set. */ 
Note: See TracChangeset for help on using the changeset viewer.