Skip to content

Commit

Permalink
Do not write a value for strings in htab.
Browse files Browse the repository at this point in the history
The assignment is unnecessary, and was overwriting the first element in the bucket (not the added string's value) in the case of a collision.
  • Loading branch information
turnage committed Jan 13, 2014
1 parent d945c9a commit e6d9d92
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions libtvm/tvm_htab.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ 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]->value = hash;
htab->nodes[hash]->valptr = calloc(len, sizeof(char));
memcpy(htab->nodes[hash]->valptr, valptr, len);
return hash;
Expand Down Expand Up @@ -161,4 +160,4 @@ char *htab_find_str(tvm_htab_t *htab, const char *key)
}

return NULL;
}
}

0 comments on commit e6d9d92

Please sign in to comment.