Remove assumption that node is in the bottom of the bucket.
This is the last remaining instance of this assumption.
This commit is contained in:
parent
e6d9d92d8c
commit
27a090e704
1 changed files with 13 additions and 2 deletions
|
|
@ -127,8 +127,19 @@ int htab_add(tvm_htab_t *htab, const char *k, int v)
|
|||
int htab_add_str(tvm_htab_t *htab, const char *key, const void *valptr, int len)
|
||||
{
|
||||
int hash = htab_add(htab, key, 0);
|
||||
htab->nodes[hash]->valptr = calloc(len, sizeof(char));
|
||||
memcpy(htab->nodes[hash]->valptr, valptr, len);
|
||||
int found = 0;
|
||||
tvm_htab_node_t *node = htab->nodes[hash];
|
||||
|
||||
while (node && !found)
|
||||
{
|
||||
if (!strcmp(node->key, key))
|
||||
found = 1;
|
||||
else
|
||||
node = node->next;
|
||||
}
|
||||
|
||||
node->valptr = calloc(len, sizeof(char));
|
||||
memcpy(node->valptr, valptr, len);
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue