DBus
1.9.11

DBusHashTable implementation details. More...
Data Structures  
struct  DBusHashEntry 
Internal representation of a hash entry. More...  
struct  DBusHashTable 
Internals of DBusHashTable. More...  
struct  DBusRealHashIter 
Internals of DBusHashIter. More...  
Macros  
#define  REBUILD_MULTIPLIER 3 
When there are this many entries per bucket, on average, rebuild the hash table to make it larger.  
#define  RANDOM_INDEX(table, i) (((((intptr_t) (i))*1103515245) >> (table)>down_shift) & (table)>mask) 
Takes a preliminary integer hash value and produces an index into a hash tables bucket list. More...  
#define  DBUS_SMALL_HASH_TABLE 4 
Initial number of buckets in hash table (hash table statically allocates its buckets for this size and below). More...  
Typedefs  
typedef struct DBusHashEntry  DBusHashEntry 
Typedef for DBusHashEntry.  
typedef DBusHashEntry *(*  DBusFindEntryFunction )(DBusHashTable *table, void *key, dbus_bool_t create_if_not_found, DBusHashEntry ***bucket, DBusPreallocatedHash *preallocated) 
Function used to find and optionally create a hash entry.  
Functions  
_DBUS_STATIC_ASSERT (sizeof(DBusRealHashIter)==sizeof(DBusHashIter))  
DBusHashTable implementation details.
The guts of DBusHashTable.
#define DBUS_SMALL_HASH_TABLE 4 
Initial number of buckets in hash table (hash table statically allocates its buckets for this size and below).
The initial mask has to be synced to this.
Definition at line 130 of file dbushash.c.
Referenced by _dbus_hash_table_new().
#define RANDOM_INDEX  (  table,  
i  
)  (((((intptr_t) (i))*1103515245) >> (table)>down_shift) & (table)>mask) 
Takes a preliminary integer hash value and produces an index into a hash tables bucket list.
The idea is to make it so that preliminary values that are arbitrarily similar will end up in different buckets. The hash function was taken from a randomnumber generator. (This is used to hash integers.)
The down_shift drops off the high bits of the hash index, and decreases as we increase the number of hash buckets (to keep more range in the hash index). The mask also strips high bits and strips fewer high bits as the number of hash buckets increases. I don't understand two things: why is the initial downshift 28 to keep 4 bits when the initial mask is 011 to keep 2 bits, and why do we have both a mask and a downshift?
Definition at line 122 of file dbushash.c.