Skip to content

Commit e6d9d92

Browse files
committed
Do not write a value for strings in htab.
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.
1 parent d945c9a commit e6d9d92

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

libtvm/tvm_htab.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ int htab_add(tvm_htab_t *htab, const char *k, int v)
127127
int htab_add_str(tvm_htab_t *htab, const char *key, const void *valptr, int len)
128128
{
129129
int hash = htab_add(htab, key, 0);
130-
htab->nodes[hash]->value = hash;
131130
htab->nodes[hash]->valptr = calloc(len, sizeof(char));
132131
memcpy(htab->nodes[hash]->valptr, valptr, len);
133132
return hash;
@@ -161,4 +160,4 @@ char *htab_find_str(tvm_htab_t *htab, const char *key)
161160
}
162161

163162
return NULL;
164-
}
163+
}

0 commit comments

Comments
 (0)