aboutsummaryrefslogtreecommitdiff
path: root/src/format.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2011-05-06 23:19:48 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2011-05-06 23:32:28 +0300
commit18d7db07b9f369901300bf664d07d4b39032ce64 (patch)
treea25c55b95491a507564b2f62a1c1abeebff636ad /src/format.c
parent352b268186931579ae8dcc6a19aaaa89547555f5 (diff)
downloadgrecs-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 'src/format.c')
-rw-r--r--src/format.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/format.c b/src/format.c
index 4d4c126..41889b7 100644
--- a/src/format.c
+++ b/src/format.c
@@ -202,9 +202,9 @@ grecs_format_node_path(struct grecs_node *node, int flags, FILE *fp)
fputc(delim ? delim : '.', fp);
fprintf(fp, "%s", node->ident);
if (node->type == grecs_node_block &&
- !GRECS_VALUE_EMPTY_P(&node->value)) {
+ !GRECS_VALUE_EMPTY_P(node->v.value)) {
fputc('=', fp);
- grecs_format_value(&node->value, flags|GRECS_NODE_FLAG_QUOTE,
+ grecs_format_value(node->v.value, flags|GRECS_NODE_FLAG_QUOTE,
fp);
}
}
@@ -253,7 +253,7 @@ grecs_format_value(struct grecs_value *val, int flags, FILE *fp)
for (i = 0; i < val->v.arg.c; i++) {
if (i)
fputc(' ', fp);
- grecs_format_value(&val->v.arg.v[i], flags, fp);
+ grecs_format_value(val->v.arg.v[i], flags, fp);
}
}
}
@@ -289,7 +289,7 @@ grecs_format_node(struct grecs_node *node, int flags, FILE *fp)
if (flags & GRECS_NODE_FLAG_VALUE) {
if (delim_str)
fprintf(fp, "%s", delim_str);
- grecs_format_value(&node->value, flags, fp);
+ grecs_format_value(node->v.value, flags, fp);
}
}
}

Return to:

Send suggestions and report system problems to the System administrator.