remove paranoid null check from BLI_ghash_lookup(), was the only ghash function with a null check, callers better check the ghash exists first.
This commit is contained in:
@@ -78,9 +78,9 @@ void BLI_ghash_insert(GHash *gh, void *key, void *val)
|
|||||||
unsigned int hash = gh->hashfp(key) % gh->nbuckets;
|
unsigned int hash = gh->hashfp(key) % gh->nbuckets;
|
||||||
Entry *e = (Entry *)BLI_mempool_alloc(gh->entrypool);
|
Entry *e = (Entry *)BLI_mempool_alloc(gh->entrypool);
|
||||||
|
|
||||||
|
e->next = gh->buckets[hash];
|
||||||
e->key = key;
|
e->key = key;
|
||||||
e->val = val;
|
e->val = val;
|
||||||
e->next = gh->buckets[hash];
|
|
||||||
gh->buckets[hash] = e;
|
gh->buckets[hash] = e;
|
||||||
|
|
||||||
if (++gh->nentries > (float)gh->nbuckets / 2) {
|
if (++gh->nentries > (float)gh->nbuckets / 2) {
|
||||||
@@ -109,13 +109,13 @@ void BLI_ghash_insert(GHash *gh, void *key, void *val)
|
|||||||
|
|
||||||
void *BLI_ghash_lookup(GHash *gh, const void *key)
|
void *BLI_ghash_lookup(GHash *gh, const void *key)
|
||||||
{
|
{
|
||||||
if (gh) {
|
const unsigned int hash = gh->hashfp(key) % gh->nbuckets;
|
||||||
unsigned int hash = gh->hashfp(key) % gh->nbuckets;
|
Entry *e;
|
||||||
Entry *e;
|
|
||||||
|
|
||||||
for (e = gh->buckets[hash]; e; e = e->next)
|
for (e = gh->buckets[hash]; e; e = e->next) {
|
||||||
if (gh->cmpfp(key, e->key) == 0)
|
if (gh->cmpfp(key, e->key) == 0) {
|
||||||
return e->val;
|
return e->val;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user