From 32c86018dc370510f768597bd465193d8bc9dcde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind?= Date: Fri, 18 Feb 2022 17:02:44 +0100 Subject: [PATCH] Added return value for the node_init - Can be used as before, but cleaner interface in parser.y --- exercises/02/vslc/src/tree.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/exercises/02/vslc/src/tree.c b/exercises/02/vslc/src/tree.c index 678888f..25aab7a 100644 --- a/exercises/02/vslc/src/tree.c +++ b/exercises/02/vslc/src/tree.c @@ -20,7 +20,8 @@ print_syntax_tree ( void ) } -void +// Changed so it returns the pointer to the new node, can be used as before, but makes the parser file cleaner +node_t* node_init (node_t *nd, node_index_t type, void *data, uint64_t n_children, ...) { // Copy the type @@ -45,6 +46,8 @@ node_init (node_t *nd, node_index_t type, void *data, uint64_t n_children, ...) // Populate the memory with pointers to children for (int i = 0; i < n_children; i++) nd->children[i] = va_arg(list_children, node_t*); + + return nd; }