diff options
Diffstat (limited to '')
-rw-r--r-- | guile_interface.scm.c | 15 | ||||
-rw-r--r-- | trie.inc.h | 4 |
2 files changed, 17 insertions, 2 deletions
diff --git a/guile_interface.scm.c b/guile_interface.scm.c index 41d13c3c..761bf7c2 100644 --- a/guile_interface.scm.c +++ b/guile_interface.scm.c @@ -68,9 +68,22 @@ SCM_DEFINE (vcomponent_set_attr_x, "%vcomponent-set-attribute!", 3, 0, 0, char* key = scm_to_utf8_stringn(scm_string_upcase(attr), NULL); content_line* c = get_property (com, key); + + /* Create the position in the TRIE if it doesn't already exist */ + if (c == NULL) { + /* Insert empty key since this allows me to use the helper + * function */ + vcomponent_push_val(com, key, ""); + c = get_property (com, key); + } else { + /* If the object already exists it should be protected, + * so unprotect it + */ + scm_gc_unprotect_object(c->cur->value->key.scm); + } + free(key); - scm_gc_unprotect_object(c->cur->value->key.scm); c->cur->value->key.scm = new_value; scm_gc_protect_object(c->cur->value->key.scm); @@ -88,6 +88,8 @@ TYPE* GET(TRIE(TYPE)) ( TRIE(TYPE)* trie, char* key ) { while (n != NULL) { if (subkey[1] == '\0') { + /* Wanted node found, + * value can however be NULL */ return n->value; } else if (subkey[0] == n->c) { n = n->child; @@ -97,7 +99,7 @@ TYPE* GET(TRIE(TYPE)) ( TRIE(TYPE)* trie, char* key ) { } } - ERR("Position not found"); + /* Position not found */ return 0; } |