]> git.droids-corp.org - protos/libecoli.git/commitdiff
x
authorOlivier Matz <zer0@droids-corp.org>
Thu, 24 Aug 2017 18:55:52 +0000 (20:55 +0200)
committerOlivier Matz <zer0@droids-corp.org>
Thu, 24 Aug 2017 18:55:52 +0000 (20:55 +0200)
lib/ecoli_completed.c
lib/ecoli_completed.h
lib/ecoli_test.c

index 88a841303c94e5a5d70749fda9bdff4efb7d86ea..0b0e641c759d58203cd0ebc9ebbf6c730b68bbab 100644 (file)
@@ -47,8 +47,8 @@ struct ec_completed *ec_completed(void)
        if (completed == NULL)
                return NULL;
 
-       TAILQ_INIT(&completed->match_items);
-       TAILQ_INIT(&completed->no_match_items);
+       TAILQ_INIT(&completed->nodes);
+       TAILQ_INIT(&completed->matches);
 
        return completed;
 }
@@ -224,7 +224,7 @@ static int ec_completed_add_item(struct ec_completed *completed,
                completed->count_match++;
        }
 
-       TAILQ_INSERT_TAIL(&completed->match_items, item, next);
+       TAILQ_INSERT_TAIL(&completed->matches, item, next);
        completed->count++;
 
        return 0;
@@ -309,9 +309,9 @@ void ec_completed_merge(struct ec_completed *completed1,
        assert(completed1 != NULL);
        assert(completed2 != NULL);
 
-       while (!TAILQ_EMPTY(&completed2->match_items)) {
-               item = TAILQ_FIRST(&completed2->match_items);
-               TAILQ_REMOVE(&completed2->match_items, item, next);
+       while (!TAILQ_EMPTY(&completed2->matches)) {
+               item = TAILQ_FIRST(&completed2->matches);
+               TAILQ_REMOVE(&completed2->matches, item, next);
                ec_completed_add_item(completed1, item);
        }
 
@@ -325,9 +325,9 @@ void ec_completed_free(struct ec_completed *completed)
        if (completed == NULL)
                return;
 
-       while (!TAILQ_EMPTY(&completed->match_items)) {
-               item = TAILQ_FIRST(&completed->match_items);
-               TAILQ_REMOVE(&completed->match_items, item, next);
+       while (!TAILQ_EMPTY(&completed->matches)) {
+               item = TAILQ_FIRST(&completed->matches);
+               TAILQ_REMOVE(&completed->matches, item, next);
                ec_completed_item_free(item);
        }
        ec_free(completed->smallest_start);
@@ -347,7 +347,7 @@ void ec_completed_dump(FILE *out, const struct ec_completed *completed)
                completed->count, completed->count_match,
                completed->smallest_start);
 
-       TAILQ_FOREACH(item, &completed->match_items, next) {
+       TAILQ_FOREACH(item, &completed->matches, next) {
                fprintf(out, "add=<%s>, node=%p, node_type=%s\n",
                        item->add, item->node, item->node->type->name);
        }
@@ -406,7 +406,7 @@ const struct ec_completed_item *ec_completed_iter_next(
 
        do {
                if (iter->cur_item == NULL)
-                       iter->cur_item = TAILQ_FIRST(&completed->match_items);
+                       iter->cur_item = TAILQ_FIRST(&completed->matches);
                else
                        iter->cur_item = TAILQ_NEXT(iter->cur_item, next);
 
index 927bb3eb7fef685d234d0ae1049d40a6266967f0..4d0045e9aeeb7861ce80831b6304a78a3442b92a 100644 (file)
@@ -53,12 +53,18 @@ struct ec_completed_item {
 
 TAILQ_HEAD(ec_completed_item_list, ec_completed_item);
 
+struct ec_completed_node {
+       const struct ec_node *node;
+};
+
+TAILQ_HEAD(ec_completed_node_list, ec_completed_node);
+
 struct ec_completed {
        unsigned count;
        unsigned count_match;
        char *smallest_start;
-       struct ec_completed_item_list match_items;
-       struct ec_completed_item_list no_match_items;
+       struct ec_completed_node_list nodes;
+       struct ec_completed_item_list matches;
 };
 
 /*
index a1dc5e717e684a44c00f5be5d043946ff9a8fa93..31f2c37be5ebf2eaaca94e617ce314a1bd90aeaa 100644 (file)
@@ -140,7 +140,7 @@ int ec_test_check_complete(struct ec_node *tk, ...)
                }
 
                count++;
-               TAILQ_FOREACH(item, &c->match_items, next) {
+               TAILQ_FOREACH(item, &c->matches, next) {
                        /* only check matching completions */
                        if (item->add != NULL && strcmp(item->add, s) == 0)
                                break;