Properly reset all commit properties when doing a gitrp_reset(). Add git_revpool_table_free() method. Signed-off-by: Vicent Marti <tanoku@gmail.com> Signed-off-by: Andreas Ericsson <ae@op5.se>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
diff --git a/src/revobject.c b/src/revobject.c
index c673654..45fb973 100644
--- a/src/revobject.c
+++ b/src/revobject.c
@@ -177,5 +177,48 @@ void git_revpool_table_resize(git_revpool_table *table)
void git_revpool_table_free(git_revpool_table *table)
{
+ int index;
+ for (index = 0; index <= table->size_mask; ++index)
+ {
+ git_revpool_node *node, *next_node;
+
+ node = table->nodes[index];
+ while (node != NULL)
+ {
+ next_node = node->next;
+ free(node);
+ node = next_node;
+ }
+ }
+
+ free(table);
+}
+
+void git_revpool_tableit_init(git_revpool_table *table, git_revpool_tableit *it)
+{
+ memset(it, 0x0, sizeof(git_revpool_tableit));
+
+ it->nodes = table->nodes;
+ it->current_node = NULL;
+ it->current_pos = 0;
+ it->size = table->size_mask + 1;
+}
+
+git_revpool_object *git_revpool_tableit_next(git_revpool_tableit *it)
+{
+ git_revpool_node *next = NULL;
+
+ while (it->current_node == NULL)
+ {
+ if (it->current_pos >= it->size)
+ return NULL;
+
+ it->current_node = it->nodes[it->current_pos++];
+ }
+
+ next = it->current_node;
+ it->current_node = it->current_node->next;
+
+ return next->object;
}
diff --git a/src/revobject.h b/src/revobject.h
index c073337..2876a4c 100644
--- a/src/revobject.h
+++ b/src/revobject.h
@@ -47,4 +47,8 @@ void git_revpool_table_resize(git_revpool_table *table);
void git_revpool_table_free(git_revpool_table *table);
+git_revpool_object *git_revpool_tableit_next(git_revpool_tableit *it);
+void git_revpool_tableit_init(git_revpool_table *table, git_revpool_tableit *it);
+
+
#endif
diff --git a/src/revwalk.c b/src/revwalk.c
index 4575d8b..60ea5e8 100644
--- a/src/revwalk.c
+++ b/src/revwalk.c
@@ -144,6 +144,18 @@ git_commit *gitrp_next(git_revpool *pool)
void gitrp_reset(git_revpool *pool)
{
+ git_commit *commit;
+ git_revpool_tableit it;
+
+ git_revpool_tableit_init(pool->commits, &it);
+
+ while ((commit = (git_commit *)git_revpool_tableit_next(&it)) != NULL)
+ {
+ commit->seen = 0;
+ commit->topo_delay = 0;
+ commit->in_degree = 0;
+ }
+
git_commit_list_clear(&pool->iterator, 0);
pool->walking = 0;
}