Changeset 748


Ignore:
Timestamp:
Oct 3, 2006 5:13:22 PM (18 years ago)
Author:
bennylp
Message:

Fixed bug in the hash table size calculation. The hash table creation API (pj_hash_create()) suggests that the size should be 2n-1, and when the size is not 2n-1, it will be rounded-up to the nearest 2n-1, except when the size is exactly 2n, then it will be rounded-down to 2n-1.

The bug caused the hash table size to be doubled when application gives 2n size (instead of rounding it down to 2n-1).

Nothing dangerous happened because of the bug, it just caused hash table size to be doubled the requirement.

Location:
pjproject/trunk/pjlib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib/include/pj/hash.h

    r127 r748  
    8484 * 
    8585 * @param pool  the pool from which the hash table will be allocated from. 
    86  * @param size  the bucket size, which will be round-up to the nearest 2^n+1 
     86 * @param size  the bucket size, which will be round-up to the nearest 2^n-1 
    8787 * 
    8888 * @return the hash table. 
  • pjproject/trunk/pjlib/src/pj/hash.c

    r623 r748  
    116116    do { 
    117117        table_size <<= 1;     
    118     } while (table_size <= size); 
     118    } while (table_size < size); 
    119119    table_size -= 1; 
    120120     
Note: See TracChangeset for help on using the changeset viewer.