aboutsummaryrefslogtreecommitdiff
path: root/trie.inc.h
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2019-02-26 11:32:02 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2019-02-26 11:32:02 +0100
commit498e984690895987067743bb94ee83d49da7ecb4 (patch)
tree773ffd98aa3e085d290b60d017c31810d7f641e1 /trie.inc.h
parentStart update of types. (diff)
downloadcalp-498e984690895987067743bb94ee83d49da7ecb4.tar.gz
calp-498e984690895987067743bb94ee83d49da7ecb4.tar.xz
Fix memmory errors.
Diffstat (limited to 'trie.inc.h')
-rw-r--r--trie.inc.h24
1 files changed, 21 insertions, 3 deletions
diff --git a/trie.inc.h b/trie.inc.h
index 90d9cb06..afa6656a 100644
--- a/trie.inc.h
+++ b/trie.inc.h
@@ -163,10 +163,28 @@ FMT_F(TRIE(TYPE)) {
return seek;
}
+int DEEP_COPY(TRIE_NODE(TYPE)) (TRIE_NODE(TYPE)* dest, TRIE_NODE(TYPE)* src) {
+ if (dest == NULL) return 1;
+ if (dest->value != NULL) {
+ RENEW(TYPE, src->value);
+ DEEP_COPY(TYPE)(src->value, dest->value);
+ }
+
+ if (dest->next != NULL) {
+ RENEW(TRIE_NODE(TYPE), src->next, dest->c);
+ DEEP_COPY(TRIE_NODE(TYPE))(src->next, dest->next);
+ }
+
+ if (dest->child != NULL) {
+ RENEW(TRIE_NODE(TYPE), src->child, dest->c);
+ DEEP_COPY(TRIE_NODE(TYPE))(src->child, dest->child);
+ }
+
+ return 0;
+}
+
int DEEP_COPY(TRIE(TYPE)) (TRIE(TYPE)* dest, TRIE(TYPE)* src) {
- (void) dest; (void) src;
- ERR(deep copy on tries currently not implemented);
- return 1;
+ return DEEP_COPY(TRIE_NODE(TYPE))(dest->root, src->root);
}
#endif /* TYPE */