diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-05-07 00:24:03 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-05-07 00:24:03 +0300 |
commit | ed39daa568d162617a183497010d70a55a38ae73 (patch) | |
tree | 313c1caef8b42ab1800f5c1cef8dece9116fbd0d /doc/grecs_parse.3 | |
parent | 18d7db07b9f369901300bf664d07d4b39032ce64 (diff) | |
download | grecs-ed39daa568d162617a183497010d70a55a38ae73.tar.gz grecs-ed39daa568d162617a183497010d70a55a38ae73.tar.bz2 |
Redo memory management (2).
* src/grecs.h (grecs_free_fun): New extern.
(grecs_free): New proto.
* src/format.c: Use grecs_free where appropriate.
* src/grecs-lex.l: Likewise.
* src/preproc.c: Likewise.
* src/tree.c: Likewise.
* src/lookup.c (parse_label): Use grecs_value_list_create.
* src/mem.c: Initialize hooks with the default values.
(grecs_free_fun): New hook.
(grecs_free): New function.
* doc/grecs_malloc.3: Document grecs_free.
* doc/grecs_parse.3: Document the recent changes.
* doc/grecs_strdup.3: Update.
Diffstat (limited to 'doc/grecs_parse.3')
-rw-r--r-- | doc/grecs_parse.3 | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/doc/grecs_parse.3 b/doc/grecs_parse.3 index 357889f..c51ef95 100644 --- a/doc/grecs_parse.3 +++ b/doc/grecs_parse.3 @@ -16,7 +16,7 @@ .\" This file is part of SLB. .\" Copyright (C) 2011 Sergey Poznyakoff .\" -.TH GRECS_PARSE 3 "May 4, 2011" "GRECS" "Grecs User Reference" +.TH GRECS_PARSE 3 "May 7, 2011" "GRECS" "Grecs User Reference" .SH NAME grecs_parse \- parse a configuration file. .SH SYNOPSIS @@ -48,14 +48,18 @@ typedef struct grecs_node { struct grecs_node *next; struct grecs_node *prev; char *ident; - struct grecs_value value; + union { + struct grecs_value *value; + struct grecs_symtab *texttab; + } v; } grecs_node_t; .in .fi .PP The \fItype\fR member describes the type of this node. Its value is -\fBgrecs_node_stmt\fR for simple statements, and -\fBgrecs_node_block\fR, for block statements. +\fBgrecs_node_stmt\fR for simple statements and +\fBgrecs_node_block\fR, for block statements. The topmost node (the +one returned by \fBgrecs_tree_parse\fR) has type \fBgrecs_node_root\fR. .PP The \fIlocus\fR describes the location in the input file, which this node described. See @@ -97,8 +101,14 @@ pidfile "/var/run/mypid"; .sp will have \fBident\fR pointing to the string \fB/var/run/mypid\fR. .PP -Finally, the \fBvalue\fR member keeps the value associated with this -statement. It is defined as: +The \fBv\fR union keeps data which depend on the type of this node. +The \fBv.texttab\fR member is defined only for the root node (type +\fBgrecs_node_root\fR). It points to a symbol table which holds shared +strings for this tree. In particular, this table holds file names +referenced by \fBlocus\fR members of all underlying nodes. +.PP +For non-root nodes,the \fBv.value\fR member is defined. It points to +the value associated with this statement. A value is defined as: .sp .nf .in +5 @@ -106,10 +116,10 @@ typedef struct grecs_value { int type; union { struct grecs_list *list; - const char *string; + char *string; struct { size_t c; - struct grecs_value *v; + struct grecs_value **v; } arg; } v; } grecs_value_t; |