fprintf(out, "%s\n", type->name);
}
-struct ec_node *__ec_node(const struct ec_node_type *type, const char *id)
+struct ec_node *ec_node_from_type(const struct ec_node_type *type, const char *id)
{
struct ec_node *node = NULL;
return NULL;
}
+const struct ec_config_schema *
+ec_node_type_schema(const struct ec_node_type *type)
+{
+ return type->schema;
+}
+
+const char *
+ec_node_type_name(const struct ec_node_type *type)
+{
+ return type->name;
+}
+
struct ec_node *ec_node(const char *typename, const char *id)
{
const struct ec_node_type *type;
return NULL;
}
- return __ec_node(type, id);
+ return ec_node_from_type(type, id);
}
static void count_references(struct ec_node *node, unsigned int refs)
if (node->free.state != EC_NODE_FREE_STATE_FREEING) {
node->free.state = EC_NODE_FREE_STATE_FREEING;
+
+ /* children will be freed by config_free() and free_priv() */
+ ec_config_free(node->config);
+ node->config = NULL;
n = ec_node_get_children_count(node);
- /* children should be freed by free_priv() */
assert(n == 0 || node->type->free_priv != NULL);
if (node->type->free_priv != NULL)
node->type->free_priv(node);
+ ec_free(node->id);
+ ec_free(node->desc);
+ ec_keyval_free(node->attrs);
}
node->refcnt--;
node->free.state = EC_NODE_FREE_STATE_NONE;
node->free.refcnt = 0;
- ec_free(node->id);
- ec_free(node->desc);
- ec_keyval_free(node->attrs);
- ec_config_free(node->config);
ec_free(node);
}
errno = EINVAL;
goto fail;
}
- if (ec_config_validate(config, node->type->schema,
- node->type->schema_len) < 0)
+ if (ec_config_validate(config, node->type->schema) < 0)
goto fail;
if (node->type->set_config != NULL) {
if (node->type->set_config(node, config) < 0)
}
}
+/* XXX this is too much debug-oriented, we should have a parameter or 2 funcs */
void ec_node_dump(FILE *out, const struct ec_node *node)
{
struct ec_keyval *dict = NULL;