Mercurial > cgi-bin > hgwebdir.cgi > VMS > C_Libraries > Hash_impl
comparison PrivateHash.c @ 32:bd376656f8ab
assuming you were not having fun thinking up silly ways to write 0
| author | Nina Engelhardt <nengel@mailbox.tu-berlin.de> |
|---|---|
| date | Wed, 24 Apr 2013 16:35:19 +0200 |
| parents | 18a72865dd78 |
| children |
comparison
equal
deleted
inserted
replaced
| 16:6bad8794df79 | 19:d13755b04ab9 |
|---|---|
| 327 int32 numHashSlots; | 327 int32 numHashSlots; |
| 328 | 328 |
| 329 retTable = VMS_int__malloc( sizeof( HashTable ) ); | 329 retTable = VMS_int__malloc( sizeof( HashTable ) ); |
| 330 | 330 |
| 331 numHashSlots = 1 << powerOf2OfSz; | 331 numHashSlots = 1 << powerOf2OfSz; |
| 332 retTable->hashMask = 0xffffffff >> 32 - powerOf2OfSz; | 332 retTable->hashMask = 0xffffffff >> (32 - powerOf2OfSz); |
| 333 retTable->prevHash = (int32)rand(); | 333 retTable->prevHash = (int32)rand(); |
| 334 | 334 |
| 335 retTable->freeEntryContentFn = freeFn; | 335 retTable->freeEntryContentFn = freeFn; |
| 336 | 336 |
| 337 retTable->entries = VMS_int__malloc( numHashSlots * sizeof(HashEntry *)); | 337 retTable->entries = VMS_int__malloc( numHashSlots * sizeof(HashEntry *)); |
| 370 { unsigned int hashIdx; | 370 { unsigned int hashIdx; |
| 371 HashEntry* testEntry; | 371 HashEntry* testEntry; |
| 372 | 372 |
| 373 testEntry = getEntryFromTable32( (uint32 *)entry->key, table ); | 373 testEntry = getEntryFromTable32( (uint32 *)entry->key, table ); |
| 374 if( testEntry == NULL ) //no entry w/key, so add passed-in as list-head | 374 if( testEntry == NULL ) //no entry w/key, so add passed-in as list-head |
| 375 { hashIdx = hashThisKey32( entry->key, table->tableSz ); | 375 { hashIdx = hashThisKey32( (uint32 *)entry->key, table ); |
| 376 entry->next = (table->entries)[hashIdx]; | 376 entry->next = (table->entries)[hashIdx]; |
| 377 (table->entries)[hashIdx] = entry; | 377 (table->entries)[hashIdx] = entry; |
| 378 table->numEntries += 1; | 378 table->numEntries += 1; |
| 379 //keep num entries less than half the num indexes in table | 379 //keep num entries less than half the num indexes in table |
| 380 if( table->numEntries > (table->tableSz >>1) ) doubleTableSize(table); | 380 if( table->numEntries > (table->tableSz >>1) ) doubleTableSize(table); |
