Commit 9bdb7594 by Vicent Marti Committed by Andreas Ericsson

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>
parent 655d381a
......@@ -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;
}
......@@ -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
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment