Extend hashtable scripts, fix hashtable with size of less than 1; correct text in spinlock tests.

This commit is contained in:
counterpoint
2014-08-27 09:31:34 +01:00
parent a853b72baf
commit eed40fef75
3 changed files with 101 additions and 13 deletions

View File

@ -98,7 +98,7 @@ HASHTABLE *rval;
rval->ht_chk_top = CHK_NUM_HASHTABLE;
rval->ht_chk_tail = CHK_NUM_HASHTABLE;
#endif
rval->hashsize = size;
rval->hashsize = size > 0 ? size : 1;
rval->hashfn = hashfn;
rval->cmpfn = cmpfn;
rval->kcopyfn = nullfn;
@ -108,12 +108,12 @@ HASHTABLE *rval;
rval->n_readers = 0;
rval->writelock = 0;
spinlock_init(&rval->spin);
if ((rval->entries = (HASHENTRIES **)calloc(size, sizeof(HASHENTRIES *))) == NULL)
if ((rval->entries = (HASHENTRIES **)calloc(rval->hashsize, sizeof(HASHENTRIES *))) == NULL)
{
free(rval);
return NULL;
}
memset(rval->entries, 0, size * sizeof(HASHENTRIES *));
memset(rval->entries, 0, rval->hashsize * sizeof(HASHENTRIES *));
return rval;
}