in sgx_ustdc/inc/inline-hashtab.h [256:298]
unsigned int (*hash_fn)(void *), int (*eq_fn)(void *, void *))
{
size_t index = 0;
unsigned int hash = 0, hash2 = 0;
size_t size = 0;
void **entry = NULL;
if (htab->size * 3 <= htab->n_elements * 4
&& htab_expand (htab, hash_fn) == 0)
return NULL;
hash = hash_fn (ptr);
size = htab->size;
index = hash % size;
entry = &htab->entries[index];
if (!*entry)
goto empty_entry;
else if (eq_fn (*entry, ptr))
return entry;
hash2 = (unsigned int)(1 + (size_t)hash % (size - 2));
for (;;)
{
index += hash2;
if (index >= size)
index -= size;
entry = &htab->entries[index];
if (!*entry)
goto empty_entry;
else if (eq_fn (*entry, ptr))
return entry;
}
empty_entry:
if (!insert)
return NULL;
htab->n_elements++;
return entry;
}