git.droids-corp.org
/
protos
/
libecoli.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
8717aff
)
use helper in seq node
author
Olivier Matz
<zer0@droids-corp.org>
Thu, 2 Aug 2018 20:04:51 +0000
(22:04 +0200)
committer
Olivier Matz
<zer0@droids-corp.org>
Thu, 2 Aug 2018 20:04:51 +0000
(22:04 +0200)
lib/ecoli_node_seq.c
patch
|
blob
|
history
diff --git
a/lib/ecoli_node_seq.c
b/lib/ecoli_node_seq.c
index
ae0bb60
..
fa49c03
100644
(file)
--- a/
lib/ecoli_node_seq.c
+++ b/
lib/ecoli_node_seq.c
@@
-18,6
+18,7
@@
#include <ecoli_config.h>
#include <ecoli_parse.h>
#include <ecoli_complete.h>
#include <ecoli_config.h>
#include <ecoli_parse.h>
#include <ecoli_complete.h>
+#include <ecoli_node_helper.h>
#include <ecoli_node_str.h>
#include <ecoli_node_option.h>
#include <ecoli_node_or.h>
#include <ecoli_node_str.h>
#include <ecoli_node_option.h>
#include <ecoli_node_or.h>
@@
-186,43
+187,25
@@
static int ec_node_seq_set_config(struct ec_node *gen_node,
const struct ec_config *config)
{
struct ec_node_seq *node = (struct ec_node_seq *)gen_node;
const struct ec_config *config)
{
struct ec_node_seq *node = (struct ec_node_seq *)gen_node;
- const struct ec_config *children = NULL, *child;
struct ec_node **table = NULL;
struct ec_node **table = NULL;
- size_t
n, i
;
+ size_t
i, len = 0
;
- children = ec_config_dict_get(config, "children");
- if (children == NULL) {
- errno = EINVAL;
- goto fail;
- }
-
- n = 0;
- TAILQ_FOREACH(child, &children->list, next)
- n++;
-
- table = ec_malloc(n * sizeof(*table));
+ table = ec_node_config_node_list_to_table(
+ ec_config_dict_get(config, "children"), &len);
if (table == NULL)
goto fail;
if (table == NULL)
goto fail;
- n = 0;
- TAILQ_FOREACH(child, &children->list, next) {
- table[n] = ec_node_clone(child->node);
- n++;
- }
-
for (i = 0; i < node->len; i++)
ec_node_free(node->table[i]);
ec_free(node->table);
node->table = table;
for (i = 0; i < node->len; i++)
ec_node_free(node->table[i]);
ec_free(node->table);
node->table = table;
- node->len = n;
+ node->len =
le
n;
return 0;
fail:
return 0;
fail:
- if (table != NULL) {
- for (i = 0; i < n; i++)
- ec_node_free(table[i]);
- }
+ for (i = 0; i < len; i++)
+ ec_node_free(table[i]);
ec_free(table);
return -1;
}
ec_free(table);
return -1;
}