From bb76c6a4d74036c9de5e75134554ca04b0b9b5cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sun, 20 Jan 2019 23:01:04 +0100 Subject: Fix some memmory errors. And discovered some new ones. --- hash_help.inc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'hash_help.inc') diff --git a/hash_help.inc b/hash_help.inc index 19463be4..ddaf4ae0 100644 --- a/hash_help.inc +++ b/hash_help.inc @@ -5,7 +5,7 @@ int HASH_PUT(TYPE) ( TABLE(TYPE)* table, TYPE* value) { // TODO genicify the hash function unsigned long h = hash(value->key.mem) % table->size; - table->values[h] = *value; + table->values[h] = value; /* TODO conflict resolution */ @@ -25,7 +25,8 @@ int HASH_INIT(TYPE) ( TABLE(TYPE)* table, int init_size ) { TYPE* HASH_GET(TYPE) ( TABLE(TYPE)* table, char* key ) { unsigned long h = hash(key) % table->size; - TYPE* mem = (table->values + h); + // TYPE* mem = (table->values + h); + TYPE* mem = table->values[h]; if (mem == NULL) { return 0; } else if (strcmp(mem->key.mem, key) == 0) { -- cgit v1.2.3