git.droids-corp.org
/
protos
/
libecoli.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
manage loops when freeing
[protos/libecoli.git]
/
lib
/
ecoli_node.h
diff --git
a/lib/ecoli_node.h
b/lib/ecoli_node.h
index
1035778
..
9bf459d
100644
(file)
--- a/
lib/ecoli_node.h
+++ b/
lib/ecoli_node.h
@@
-82,6
+82,9
@@
typedef int (*ec_node_complete_t)(const struct ec_node *node,
typedef const char * (*ec_node_desc_t)(const struct ec_node *);
typedef int (*ec_node_init_priv_t)(struct ec_node *);
typedef void (*ec_node_free_priv_t)(struct ec_node *);
typedef const char * (*ec_node_desc_t)(const struct ec_node *);
typedef int (*ec_node_init_priv_t)(struct ec_node *);
typedef void (*ec_node_free_priv_t)(struct ec_node *);
+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);
/**
* A structure describing a node type.
/**
* A structure describing a node type.
@@
-99,6
+102,8
@@
struct ec_node_type {
size_t size;
ec_node_init_priv_t init_priv;
ec_node_free_priv_t free_priv;
size_t size;
ec_node_init_priv_t init_priv;
ec_node_free_priv_t free_priv;
+ ec_node_get_children_count_t get_children_count;
+ ec_node_get_child_t get_child;
};
/**
};
/**
@@
-127,6
+132,14
@@
const struct ec_node_type *ec_node_type_lookup(const char *name);
*/
void ec_node_type_dump(FILE *out);
*/
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. */
struct ec_node {
const struct ec_node_type *type;
struct ec_config *config; /**< Generic configuration. */
@@
-134,8
+147,11
@@
struct ec_node {
char *desc;
struct ec_keyval *attrs;
unsigned int refcnt;
char *desc;
struct ec_keyval *attrs;
unsigned int refcnt;
- struct ec_node **children; /* array of children */
- size_t n_children; /* number of children in the array */
+ 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
};
/* create a new node when the type is known, typically called from the node
@@
-149,10
+165,14
@@
struct ec_node *ec_node_clone(struct ec_node *node);
void ec_node_free(struct ec_node *node);
/* set configuration of a node
void ec_node_free(struct ec_node *node);
/* set configuration of a node
- * after a call to this function, the config is owned by the node and
- * must not be used by the caller */
+ * after a call to this function, the config is
+ * owned by the node and must not be used by the caller
+ * on error, the config is freed. */
int ec_node_set_config(struct ec_node *node, struct ec_config *config);
int ec_node_set_config(struct ec_node *node, struct ec_config *config);
+/* get the current node configuration. Return NULL if no configuration. */
+const struct ec_config *ec_node_get_config(struct ec_node *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);
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);