diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-05-06 23:19:48 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-05-06 23:32:28 +0300 |
commit | 18d7db07b9f369901300bf664d07d4b39032ce64 (patch) | |
tree | a25c55b95491a507564b2f62a1c1abeebff636ad /tests | |
parent | 352b268186931579ae8dcc6a19aaaa89547555f5 (diff) | |
download | grecs-18d7db07b9f369901300bf664d07d4b39032ce64.tar.gz grecs-18d7db07b9f369901300bf664d07d4b39032ce64.tar.bz2 |
Redo memory management (1).
* src/grecs-lex.l (grecs_lex_end): Free both lists.
Additional argument specifies if string data should be
freed as well (on error).
(grecs_value_dup): Don't append to string_list.
* src/grecs.h (grecs_value) <v.string>: Remove const qualifier.
<v.arg.v>: Array of struct grecs_value pointers.
(grecs_node)<value>: Move to the union v.
<v.texttab>: Text storage table (for grecs_node_root).
(grecs_lex_end): Fix prototype.
(grecs_value_list_create): New prototype.
(grecs_value_free: New prototype.
(grecs_value_dup): Rename to grecs_value_ptr_from_static.
* src/text.c (grecs_text_table): New function.
* src/tree.c (grecs_value_free): New function.
(grecs_node_free): Reimplement.
(grecs_tree_free): Rewrite using grecs_tree_recurse.
(grecs_string_convert): strdup string values.
(grecs_value_list_create): New function.
* tests/gcffmt.c: Call grecs_tree_free.
* tests/gcfpeek.c: Likewise.
* tests/gcfset.c: Likewise.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/gcffmt.c | 1 | ||||
-rw-r--r-- | tests/gcfpeek.c | 1 | ||||
-rw-r--r-- | tests/gcfset.c | 1 |
3 files changed, 3 insertions, 0 deletions
diff --git a/tests/gcffmt.c b/tests/gcffmt.c index 29aa69a..64a4f63 100644 --- a/tests/gcffmt.c +++ b/tests/gcffmt.c @@ -80,5 +80,6 @@ main(int argc, char **argv) grecs_format_node(node, flags, stdout); fputc('\n', stdout); } + grecs_tree_free(tree); exit(0); } diff --git a/tests/gcfpeek.c b/tests/gcfpeek.c index 905f4ca..5ff8583 100644 --- a/tests/gcfpeek.c +++ b/tests/gcfpeek.c @@ -79,5 +79,6 @@ main(int argc, char **argv) grecs_format_node(node, flags, stdout); fputc('\n', stdout); } + grecs_tree_free(tree); exit(rc); } diff --git a/tests/gcfset.c b/tests/gcfset.c index 8d5b464..f41d67f 100644 --- a/tests/gcfset.c +++ b/tests/gcfset.c @@ -219,6 +219,7 @@ main(int argc, char **argv) if (grecs_tree_process(tree, main_kwtab)) exit(2); + grecs_tree_free(tree); printf("Global settings:\n"); printf("scalar = %s\n", S(scalar_string)); |