summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/revobject.c43
-rw-r--r--src/revobject.h4
-rw-r--r--src/revwalk.c12
3 files changed, 59 insertions, 0 deletions
diff --git a/src/revobject.c b/src/revobject.c
index c6736542f..45fb97389 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 c073337a4..2876a4c21 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 4575d8b63..60ea5e87d 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;
}