typedef size_t (*ec_node_get_children_count_t)(const struct ec_node *);
typedef struct ec_node * (*ec_node_get_child_t)(const struct ec_node *,
size_t i);
+typedef unsigned int (*ec_node_get_child_refs_t)(const struct ec_node *,
+ size_t i);
/**
* A structure describing a node type.
ec_node_free_priv_t free_priv;
ec_node_get_children_count_t get_children_count;
ec_node_get_child_t get_child;
+ ec_node_get_child_refs_t get_child_refs;
};
/**
*/
void ec_node_type_dump(FILE *out);
+enum ec_node_free_state {
+ EC_NODE_FREE_STATE_NONE,
+ EC_NODE_FREE_STATE_TRAVERSED,
+ EC_NODE_FREE_STATE_FREEABLE,
+ EC_NODE_FREE_STATE_NOT_FREEABLE,
+ EC_NODE_FREE_STATE_FREEING,
+};
+
struct ec_node {
const struct ec_node_type *type;
struct ec_config *config; /**< Generic configuration. */
char *desc;
struct ec_keyval *attrs;
unsigned int refcnt;
+ struct {
+ enum ec_node_free_state state; /**< State of loop detection */
+ unsigned int refcnt; /**< Number of reachable references
+ * starting from node beeing freed */
+ } free; /**< Freeing state: used for loop detection */
};
/* create a new node when the type is known, typically called from the node
size_t ec_node_get_children_count(const struct ec_node *node);
struct ec_node *
ec_node_get_child(const struct ec_node *node, size_t i);
-int ec_node_add_child(struct ec_node *node, struct ec_node *child);
-int ec_node_del_child(struct ec_node *node, struct ec_node *child);
+unsigned int
+ec_node_get_child_refs(const struct ec_node *node, size_t i);
/* XXX add more accessors */
const struct ec_node_type *ec_node_type(const struct ec_node *node);