X-Git-Url: http://git.droids-corp.org/?p=protos%2Flibecoli.git;a=blobdiff_plain;f=libecoli_yaml%2Fecoli_yaml.c;h=76592e272df166199933bed99b0ee811aaa852c8;hp=850b414f89fc94a368f414f77afa29969732f420;hb=181334a4cd586d3c958898dd19291b856c461dee;hpb=4f6306bf7d571b2789001291ab743255e9de34f5 diff --git a/libecoli_yaml/ecoli_yaml.c b/libecoli_yaml/ecoli_yaml.c index 850b414..76592e2 100644 --- a/libecoli_yaml/ecoli_yaml.c +++ b/libecoli_yaml/ecoli_yaml.c @@ -11,6 +11,9 @@ #include #include + +#include +#include #include #include #include @@ -348,7 +351,8 @@ parse_ec_node(struct enode_table *table, { const struct ec_config_schema *schema; const struct ec_node_type *type = NULL; - const char *id = NULL, *help = NULL; + const char *id = NULL; + char *help = NULL; struct ec_config *config = NULL; const yaml_node_t *attrs = NULL; const yaml_node_t *key, *value; @@ -412,7 +416,11 @@ parse_ec_node(struct enode_table *table, fprintf(stderr, "Help must be a scalar\n"); goto fail; } - help = value_str; + help = ec_strdup(value_str); + if (help == NULL) { + fprintf(stderr, "Failed to allocate help\n"); + goto fail; + } } } @@ -446,6 +454,16 @@ parse_ec_node(struct enode_table *table, goto fail; } + if (help != NULL) { + if (ec_keyval_set(ec_node_attrs(enode), "help", help, + ec_free_func) < 0) { + fprintf(stderr, "Failed to set help\n"); + help = NULL; + goto fail; + } + help = NULL; + } + /* add attributes (all as string) */ //XXX @@ -454,6 +472,8 @@ parse_ec_node(struct enode_table *table, fail: ec_node_free(enode); ec_config_free(config); + ec_free(help); + return NULL; }