aboutsummaryrefslogtreecommitdiff
path: root/trie.inc
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2019-01-22 14:16:30 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2019-01-22 14:18:19 +0100
commitdba60d8b985247be7f0b0eef0bc0cefef651c824 (patch)
tree853afca0b32884c279e1a949313873f9c0d649d6 /trie.inc
parentStart using trie's instead of hash-maps. (diff)
downloadcalp-dba60d8b985247be7f0b0eef0bc0cefef651c824.tar.gz
calp-dba60d8b985247be7f0b0eef0bc0cefef651c824.tar.xz
Fix crash.
Diffstat (limited to 'trie.inc')
-rw-r--r--trie.inc13
1 files changed, 8 insertions, 5 deletions
diff --git a/trie.inc b/trie.inc
index 96765c2f..a3207bb1 100644
--- a/trie.inc
+++ b/trie.inc
@@ -4,15 +4,18 @@
#include "err.h"
-int TRIE_INIT(TYPE) ( TRIE(TYPE)* trie ) {
- NEW(TRIE_NODE(TYPE), t, '\0');
- trie->root = t;
+int CONSTRUCTOR_DECL ( TRIE(TYPE) ) {
+ // NEW(TRIE_NODE(TYPE), t, '\0');
+ TRIE_NODE(TYPE)* t = malloc(sizeof(*t));
+ CONSTRUCT(TRIE_NODE(content_line), t, '\0');
+ this->root = t;
return 0;
}
int CONSTRUCTOR_DECL (TRIE_NODE(TYPE), char c) {
this->c = c;
- this->next = NULL;
+ this->value = NULL;
+ this->next = NULL;
this->child = NULL;
return 0;
}
@@ -97,7 +100,7 @@ TYPE* TRIE_GET(TYPE) ( TRIE(TYPE)* trie, char* key ) {
int TRIE_NODE_FREE(TYPE) ( TRIE_NODE(TYPE)* node ) {
if (node == NULL) return 0;
- if (node->value != NULL) free (node->value);
+ if (node->value != NULL) FFREE(TYPE, node->value);
if (node->next != NULL) TRIE_NODE_FREE(TYPE)(node->next);
if (node->child != NULL) TRIE_NODE_FREE(TYPE)(node->child);
return 0;