X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Fecoli_node_option.c;h=ab4f35265e43fe0190c2e8b009509d9173bad29a;hb=dec2d7fa17ae1e8b3d1dec8e396d057757baf4f3;hp=b4bb391d8c4b2fbd319307881228d5c0b7d756b8;hpb=8c1e15f7d7e507c02f41ef9c3dbe310005ce369f;p=protos%2Flibecoli.git diff --git a/lib/ecoli_node_option.c b/lib/ecoli_node_option.c index b4bb391..ab4f352 100644 --- a/lib/ecoli_node_option.c +++ b/lib/ecoli_node_option.c @@ -54,6 +54,13 @@ ec_node_option_complete(const struct ec_node *gen_node, return ec_node_complete_child(node->child, comp, strvec); } +static void ec_node_option_free_priv(struct ec_node *gen_node) +{ + struct ec_node_option *node = (struct ec_node_option *)gen_node; + + ec_node_free(node->child); +} + static size_t ec_node_option_get_children_count(const struct ec_node *gen_node) { @@ -64,15 +71,18 @@ ec_node_option_get_children_count(const struct ec_node *gen_node) return 0; } -static struct ec_node * -ec_node_option_get_child(const struct ec_node *gen_node, size_t i) +static int +ec_node_option_get_child(const struct ec_node *gen_node, size_t i, + struct ec_node **child, unsigned int *refs) { struct ec_node_option *node = (struct ec_node_option *)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_option_type = { @@ -80,6 +90,7 @@ static struct ec_node_type ec_node_option_type = { .parse = ec_node_option_parse, .complete = ec_node_option_complete, .size = sizeof(struct ec_node_option), + .free_priv = ec_node_option_free_priv, .get_children_count = ec_node_option_get_children_count, .get_child = ec_node_option_get_child, }; @@ -114,7 +125,7 @@ struct ec_node *ec_node_option(const char *id, struct ec_node *child) if (child == NULL) goto fail; - gen_node = __ec_node(&ec_node_option_type, id); + gen_node = ec_node_from_type(&ec_node_option_type, id); if (gen_node == NULL) goto fail;