diff options
| author | Quentin Young <qlyoung@cumulusnetworks.com> | 2016-07-27 04:17:51 +0000 |
|---|---|---|
| committer | Quentin Young <qlyoung@cumulusnetworks.com> | 2016-07-27 04:17:51 +0000 |
| commit | 5a5d576b346b03888636bcb0af31efb8a1e43cc2 (patch) | |
| tree | bfeb3996db5c654845d21be484d88f1bd95b7eda /lib/command_graph.h | |
| parent | eceb106640e0279ed89e476c25f37f3b2da860fc (diff) | |
lib: Cleanup parser memory management
Free as appropriate. Additionally add new type
of node to demark graph head (START_GN).
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'lib/command_graph.h')
| -rw-r--r-- | lib/command_graph.h | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/command_graph.h b/lib/command_graph.h index f0ded21262..f82bbd052b 100644 --- a/lib/command_graph.h +++ b/lib/command_graph.h @@ -16,6 +16,7 @@ enum graph_node_type SELECTOR_GN, OPTION_GN, NUL_GN, + START_GN, END_GN }; @@ -26,9 +27,9 @@ struct graph_node vector children; // this node's children struct graph_node * end; // pointer to end for SELECTOR_GN & OPTION_GN - char* text; // for WORD_GN and VARIABLE_GN - long value; // for NUMBER_GN - long min, max; // for RANGE_GN + char* text; // for WORD_GN and VARIABLE_GN + long value; // for NUMBER_GN + long min, max; // for RANGE_GN /* cmd_element struct pointer, only valid for END_GN */ struct cmd_element *element; @@ -37,14 +38,14 @@ struct graph_node }; /* - * Adds a child to a node. - * If the node already has the exact same child, nothing is done. This is - * decided with cmp_node. + * Adds a node as a child of another node. + * If the new parent has a child that is equal to the prospective child, as + * determined by cmp_node, then a pointer to the existing node is returned and + * the prospective child is not added. Otherwise the return value is NULL. * * @param[in] parent node * @param[in] child node - * @return the new child, or the existing child if the parent already has the - * new child + * @return pointer to child if it is added, pointer to existing child otherwise */ extern struct graph_node * add_node(struct graph_node *, struct graph_node *); |
