len = nb * nHTBuckets; /* new hash table length */
mht->size = nb * sizeof(struct memoryHTBlock *);
- b = mht->blocks = (struct memoryHTBlock **)malloc(mht->size);
- memset(b, 0, mht->size);
+ b = mht->blocks = calloc(1, mht->size);
for (i = 0; i < nb; i++) {
- b[i] = (struct memoryHTBlock *)malloc(sizeof(struct memoryHTBlock));
+ b[i] = malloc(sizeof(struct memoryHTBlock));
code = AllocBlock(ut, (struct block *)&b[i]->b, &b[i]->a);
if (code)
return code;
if (*blocksP == 0) {
*sizeP = ht_TableSize(length);
- *blocksP = (struct memoryHTBlock **)malloc(*sizeP);
- memset(*blocksP, 0, *sizeP);
+ *blocksP = calloc(1, *sizeP);
}
n = *sizeP / sizeof(struct memoryHTBlock *);
if (bi >= n)
db_panic("non-zero length, but no table");
}
/* else ta is set from last time around loop */
- b[i] =
- (struct memoryHTBlock *)malloc(sizeof(struct memoryHTBlock));
+ b[i] = malloc(sizeof(struct memoryHTBlock));
b[i]->a = ta;
b[i]->valid = 0;
}
switch (type) {
case HT_dumpIden_FUNCTION:
retval = IdHashFunction(ntohl(((struct dump *)e)->id));
- LogDebug(5, "HashEntry: dumpid returns %d\n", retval);
+ LogDebug(5, "HashEntry: dumpid returns %u\n", retval);
break;
case HT_dumpName_FUNCTION:
retval = StringHashFunction((unsigned char *)((struct dump *)e)->dumpName);
- LogDebug(5, "HashEntry: dumpname returns %d\n", retval);
+ LogDebug(5, "HashEntry: dumpname returns %u\n", retval);
break;
case HT_tapeName_FUNCTION:
retval = StringHashFunction((unsigned char *)((struct tape *)e)->name);
- LogDebug(5, "HashEntry: tapename returns %d\n", retval);
+ LogDebug(5, "HashEntry: tapename returns %u\n", retval);
break;
case HT_volName_FUNCTION:
retval = StringHashFunction((unsigned char *)((struct volInfo *)e)->name);
- LogDebug(5, "HashEntry: volname returns %d\n", retval);
+ LogDebug(5, "HashEntry: volname returns %u\n", retval);
break;
default:
for (ea = listA; ea; ea = next_ea) { /*f */
- LogDebug(3, "ht_HashInList: move entry at %d, type %d\n", ea,
+ LogDebug(3, "ht_HashInList: move entry at %u, type %d\n", ea,
ntohl(mht->ht->functionType));
if (dbread(ut, ea, e, e_size))
return BUDB_IO;
- /* LogNetDump((struct dump *) e); */
-
/* get the address of the next item on the list */
next_ea = ntohl(*(dbadr *) (e + mht->threadOffset));
/* get the hash value */
hash = ht_HashEntry(mht, e) % mht->length;
- LogDebug(4, "ht_HashInList: moved to %d\n", hash);
+ LogDebug(4, "ht_HashInList: moved to %u\n", hash);
/* get the new hash table block */
code = ht_GetTableBlock(ut, mht, hash, 0 /*old */ , &block, &bo);
code = set_word_offset(ut, ea, e, mht->threadOffset, block->b.bucket[bo]);
if (code)
return BUDB_IO;
- LogDebug(5, "Hashin: set %d to %d\n", mht->threadOffset,
+ LogDebug(5, "Hashin: set %d to %u\n", mht->threadOffset,
block->b.bucket[bo]);
code =
int entrySize; /* hashed entry size */
char entry[sizeof(struct block)];
- dbadr entryAddr, nextEntryAddr;
+ dbadr entryAddr;
int i;
*/
for (i = 0; (i < nHTBuckets) && (index < length); i++, index++) { /*f */
- entryAddr = 0;
- nextEntryAddr = ntohl(htBlockPtr->bucket[i]);
+ entryAddr = ntohl(htBlockPtr->bucket[i]);
/* if this is the old hash table, all entries below the progress mark
* should have been moved to the new hash table
*/
- if (old && (index < mhtPtr->progress) && nextEntryAddr)
+ if (old && (index < mhtPtr->progress) && entryAddr)
return BUDB_INTERNALERROR;
/* now walk down the chain of each bucket */
- while (nextEntryAddr) { /*w */
+ while (entryAddr) { /*w */
- entryAddr = nextEntryAddr;
if (dbread(ut, entryAddr, &entry[0], entrySize))
return (BUDB_INTERNALERROR);
(*operationFn) (entryAddr, &entry[0], rockPtr);
}
- nextEntryAddr =
+ entryAddr =
ntohl(*((dbadr *) (entry + mhtPtr->threadOffset)));
} /*w */