Skip to content

Commit

Permalink
#30 don't ovewrite existing keys in hashtable
Browse files Browse the repository at this point in the history
  • Loading branch information
koekeishiya committed Mar 30, 2018
1 parent 9096762 commit da52cf6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/hashtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ void table_add(struct table *table, void *key, void *value)
{
struct bucket **bucket = table_get_bucket(table, key);
if (*bucket) {
(*bucket)->value = value;
if (!(*bucket)->value) {
(*bucket)->value = value;
}
} else {
*bucket = table_new_bucket(key, value);
++table->count;
Expand Down

0 comments on commit da52cf6

Please sign in to comment.