diff options
author | Hugo Hörnquist <hugo@hornquist.se> | 2019-01-20 23:01:04 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@hornquist.se> | 2019-01-20 23:01:04 +0100 |
commit | bb76c6a4d74036c9de5e75134554ca04b0b9b5cb (patch) | |
tree | 809b8c9b1240be540c581a6e28ac0fcdb75c8dde /hash_help.inc | |
parent | Set SAFE_STR in makefile. (diff) | |
download | calp-bb76c6a4d74036c9de5e75134554ca04b0b9b5cb.tar.gz calp-bb76c6a4d74036c9de5e75134554ca04b0b9b5cb.tar.xz |
Fix some memmory errors.
And discovered some new ones.
Diffstat (limited to 'hash_help.inc')
-rw-r--r-- | hash_help.inc | 5 |
1 files changed, 3 insertions, 2 deletions
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) { |