object: clear grafts when clearing parsed object pool
We do not clear grafts part of the parsed object pool when clearing the pool itself, which can lead to memory leaks when a repository is being cleared. Fix this by moving `reset_commit_grafts()` into "object.c" and making it part of the `struct parsed_object_pool` interface such that we can call it from `parsed_object_pool_clear()`. Adapt `parsed_object_pool_new()` to take and store a reference to its owning repository, which is needed by `unparse_commit()`. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
b8849e236f
commit
0d1d22f5a3
14
commit.c
14
commit.c
@ -177,7 +177,7 @@ int commit_graft_pos(struct repository *r, const struct object_id *oid)
|
||||
commit_graft_oid_access);
|
||||
}
|
||||
|
||||
static void unparse_commit(struct repository *r, const struct object_id *oid)
|
||||
void unparse_commit(struct repository *r, const struct object_id *oid)
|
||||
{
|
||||
struct commit *c = lookup_commit(r, oid);
|
||||
|
||||
@ -318,18 +318,6 @@ int for_each_commit_graft(each_commit_graft_fn fn, void *cb_data)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void reset_commit_grafts(struct repository *r)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < r->parsed_objects->grafts_nr; i++) {
|
||||
unparse_commit(r, &r->parsed_objects->grafts[i]->oid);
|
||||
free(r->parsed_objects->grafts[i]);
|
||||
}
|
||||
r->parsed_objects->grafts_nr = 0;
|
||||
r->parsed_objects->commit_graft_prepared = 0;
|
||||
}
|
||||
|
||||
struct commit_buffer {
|
||||
void *buffer;
|
||||
unsigned long size;
|
||||
|
Reference in New Issue
Block a user