X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Fecoli_node_many.c;h=1c91f855ed388d1dec6193ed4a368379896d45a3;hb=15718f19cbf3868bf6fba79f4e26b5254c57873e;hp=728f1c64f2b6c3b04344aa5dbaeb1761858be0cd;hpb=8c1e15f7d7e507c02f41ef9c3dbe310005ce369f;p=protos%2Flibecoli.git diff --git a/lib/ecoli_node_many.c b/lib/ecoli_node_many.c index 728f1c6..1c91f85 100644 --- a/lib/ecoli_node_many.c +++ b/lib/ecoli_node_many.c @@ -154,6 +154,13 @@ ec_node_many_complete(const struct ec_node *gen_node, strvec); } +static void ec_node_many_free_priv(struct ec_node *gen_node) +{ + struct ec_node_many *node = (struct ec_node_many *)gen_node; + + ec_node_free(node->child); +} + static size_t ec_node_many_get_children_count(const struct ec_node *gen_node) { @@ -164,15 +171,18 @@ ec_node_many_get_children_count(const struct ec_node *gen_node) return 0; } -static struct ec_node * -ec_node_many_get_child(const struct ec_node *gen_node, size_t i) +static int +ec_node_many_get_child(const struct ec_node *gen_node, size_t i, + struct ec_node **child, unsigned int *refs) { struct ec_node_many *node = (struct ec_node_many *)gen_node; if (i >= 1) - return NULL; + return -1; - return node->child; + *child = node->child; + *refs = 1; + return 0; } static struct ec_node_type ec_node_many_type = { @@ -180,6 +190,7 @@ static struct ec_node_type ec_node_many_type = { .parse = ec_node_many_parse, .complete = ec_node_many_complete, .size = sizeof(struct ec_node_many), + .free_priv = ec_node_many_free_priv, .get_children_count = ec_node_many_get_children_count, .get_child = ec_node_many_get_child, }; @@ -194,7 +205,7 @@ struct ec_node *ec_node_many(const char *id, struct ec_node *child, if (child == NULL) return NULL; - node = (struct ec_node_many *)__ec_node(&ec_node_many_type, id); + node = (struct ec_node_many *)ec_node_from_type(&ec_node_many_type, id); if (node == NULL) { ec_node_free(child); return NULL;