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
simplify config list to node table
[protos/libecoli.git]
/
libecoli
/
ecoli_node_helper.c
diff --git
a/libecoli/ecoli_node_helper.c
b/libecoli/ecoli_node_helper.c
index
9ec7e89
..
94811f2
100644
(file)
--- a/
libecoli/ecoli_node_helper.c
+++ b/
libecoli/ecoli_node_helper.c
@@
-19,7
+19,7
@@
ec_node_config_node_list_to_table(const struct ec_config *config,
{
struct ec_node **table = NULL;
struct ec_config *child;
{
struct ec_node **table = NULL;
struct ec_config *child;
- size_t n, i;
+ s
s
ize_t n, i;
*len = 0;
*len = 0;
@@
-33,21
+33,20
@@
ec_node_config_node_list_to_table(const struct ec_config *config,
return NULL;
}
return NULL;
}
- n = 0;
- TAILQ_FOREACH(child, &config->list, next) {
- if (ec_config_get_type(child) != EC_CONFIG_TYPE_NODE) {
- errno = EINVAL;
- return NULL;
- }
- n++;
- }
+ n = ec_config_count(config);
+ if (n < 0)
+ return NULL;
- table = ec_
malloc(n *
sizeof(*table));
+ table = ec_
calloc(n,
sizeof(*table));
if (table == NULL)
goto fail;
n = 0;
TAILQ_FOREACH(child, &config->list, next) {
if (table == NULL)
goto fail;
n = 0;
TAILQ_FOREACH(child, &config->list, next) {
+ if (ec_config_get_type(child) != EC_CONFIG_TYPE_NODE) {
+ errno = EINVAL;
+ goto fail;
+ }
table[n] = ec_node_clone(child->node);
n++;
}
table[n] = ec_node_clone(child->node);
n++;
}