#include <assert.h>
#include <yaml.h>
+
+#include <ecoli_malloc.h>
+#include <ecoli_keyval.h>
#include <ecoli_node.h>
#include <ecoli_config.h>
#include <ecoli_yaml.h>
if (enode == NULL)
goto fail;
config = ec_config_node(enode);
+ enode = NULL;
if (config == NULL) {
fprintf(stderr, "Failed to create config\n");
goto fail;
{
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;
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;
+ }
}
}
goto fail;
if (ec_node_set_config(enode, config) < 0) {
+ config = NULL; /* freed */
fprintf(stderr, "Failed to set config\n");
goto fail;
}
+ config = NULL; /* freed */
+
+ 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
fail:
ec_node_free(enode);
ec_config_free(config);
+ ec_free(help);
+
return NULL;
}