mirror of
https://github.com/git/git.git
synced 2024-05-09 16:06:10 +02:00
commit: prepare free_commit_buffer and release_commit_memory for any repo
Pass the object pool to free_commit_buffer and release_commit_memory,
such that we can eliminate access to 'the_repository'.
Also remove the TODO in release_commit_memory, as commit->util was
removed in 9d2c97016f
(commit.h: delete 'util' field in struct commit,
2018-05-19)
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
4f542b7a7f
commit
6a7895fd8a
|
@ -382,7 +382,8 @@ static int fsck_obj(struct object *obj, void *buffer, unsigned long size)
|
||||||
if (obj->type == OBJ_TREE)
|
if (obj->type == OBJ_TREE)
|
||||||
free_tree_buffer((struct tree *)obj);
|
free_tree_buffer((struct tree *)obj);
|
||||||
if (obj->type == OBJ_COMMIT)
|
if (obj->type == OBJ_COMMIT)
|
||||||
free_commit_buffer((struct commit *)obj);
|
free_commit_buffer(the_repository->parsed_objects,
|
||||||
|
(struct commit *)obj);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -395,7 +395,8 @@ static int cmd_log_walk(struct rev_info *rev)
|
||||||
* We may show a given commit multiple times when
|
* We may show a given commit multiple times when
|
||||||
* walking the reflogs.
|
* walking the reflogs.
|
||||||
*/
|
*/
|
||||||
free_commit_buffer(commit);
|
free_commit_buffer(the_repository->parsed_objects,
|
||||||
|
commit);
|
||||||
free_commit_list(commit->parents);
|
free_commit_list(commit->parents);
|
||||||
commit->parents = NULL;
|
commit->parents = NULL;
|
||||||
}
|
}
|
||||||
|
@ -1922,7 +1923,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
|
||||||
open_next_file(rev.numbered_files ? NULL : commit, NULL, &rev, quiet))
|
open_next_file(rev.numbered_files ? NULL : commit, NULL, &rev, quiet))
|
||||||
die(_("Failed to create output files"));
|
die(_("Failed to create output files"));
|
||||||
shown = log_tree_commit(&rev, commit);
|
shown = log_tree_commit(&rev, commit);
|
||||||
free_commit_buffer(commit);
|
free_commit_buffer(the_repository->parsed_objects,
|
||||||
|
commit);
|
||||||
|
|
||||||
/* We put one extra blank line between formatted
|
/* We put one extra blank line between formatted
|
||||||
* patches and this flag is used by log-tree code
|
* patches and this flag is used by log-tree code
|
||||||
|
|
|
@ -196,7 +196,8 @@ static void finish_commit(struct commit *commit, void *data)
|
||||||
free_commit_list(commit->parents);
|
free_commit_list(commit->parents);
|
||||||
commit->parents = NULL;
|
commit->parents = NULL;
|
||||||
}
|
}
|
||||||
free_commit_buffer(commit);
|
free_commit_buffer(the_repository->parsed_objects,
|
||||||
|
commit);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void finish_object__ma(struct object *obj)
|
static inline void finish_object__ma(struct object *obj)
|
||||||
|
|
9
commit.c
9
commit.c
|
@ -328,10 +328,10 @@ void repo_unuse_commit_buffer(struct repository *r,
|
||||||
free((void *)buffer);
|
free((void *)buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void free_commit_buffer(struct commit *commit)
|
void free_commit_buffer(struct parsed_object_pool *pool, struct commit *commit)
|
||||||
{
|
{
|
||||||
struct commit_buffer *v = buffer_slab_peek(
|
struct commit_buffer *v = buffer_slab_peek(
|
||||||
the_repository->parsed_objects->buffer_slab, commit);
|
pool->buffer_slab, commit);
|
||||||
if (v) {
|
if (v) {
|
||||||
FREE_AND_NULL(v->buffer);
|
FREE_AND_NULL(v->buffer);
|
||||||
v->size = 0;
|
v->size = 0;
|
||||||
|
@ -354,13 +354,12 @@ struct object_id *get_commit_tree_oid(const struct commit *commit)
|
||||||
return &get_commit_tree(commit)->object.oid;
|
return &get_commit_tree(commit)->object.oid;
|
||||||
}
|
}
|
||||||
|
|
||||||
void release_commit_memory(struct commit *c)
|
void release_commit_memory(struct parsed_object_pool *pool, struct commit *c)
|
||||||
{
|
{
|
||||||
c->maybe_tree = NULL;
|
c->maybe_tree = NULL;
|
||||||
c->index = 0;
|
c->index = 0;
|
||||||
free_commit_buffer(c);
|
free_commit_buffer(pool, c);
|
||||||
free_commit_list(c->parents);
|
free_commit_list(c->parents);
|
||||||
/* TODO: what about commit->util? */
|
|
||||||
|
|
||||||
c->object.parsed = 0;
|
c->object.parsed = 0;
|
||||||
}
|
}
|
||||||
|
|
4
commit.h
4
commit.h
|
@ -140,7 +140,7 @@ void repo_unuse_commit_buffer(struct repository *r,
|
||||||
/*
|
/*
|
||||||
* Free any cached object buffer associated with the commit.
|
* Free any cached object buffer associated with the commit.
|
||||||
*/
|
*/
|
||||||
void free_commit_buffer(struct commit *);
|
void free_commit_buffer(struct parsed_object_pool *pool, struct commit *);
|
||||||
|
|
||||||
struct tree *get_commit_tree(const struct commit *);
|
struct tree *get_commit_tree(const struct commit *);
|
||||||
struct object_id *get_commit_tree_oid(const struct commit *);
|
struct object_id *get_commit_tree_oid(const struct commit *);
|
||||||
|
@ -149,7 +149,7 @@ struct object_id *get_commit_tree_oid(const struct commit *);
|
||||||
* Release memory related to a commit, including the parent list and
|
* Release memory related to a commit, including the parent list and
|
||||||
* any cached object buffer.
|
* any cached object buffer.
|
||||||
*/
|
*/
|
||||||
void release_commit_memory(struct commit *c);
|
void release_commit_memory(struct parsed_object_pool *pool, struct commit *c);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Disassociate any cached object buffer from the commit, but do not free it.
|
* Disassociate any cached object buffer from the commit, but do not free it.
|
||||||
|
|
2
object.c
2
object.c
|
@ -540,7 +540,7 @@ void parsed_object_pool_clear(struct parsed_object_pool *o)
|
||||||
if (obj->type == OBJ_TREE)
|
if (obj->type == OBJ_TREE)
|
||||||
free_tree_buffer((struct tree*)obj);
|
free_tree_buffer((struct tree*)obj);
|
||||||
else if (obj->type == OBJ_COMMIT)
|
else if (obj->type == OBJ_COMMIT)
|
||||||
release_commit_memory((struct commit*)obj);
|
release_commit_memory(o, (struct commit*)obj);
|
||||||
else if (obj->type == OBJ_TAG)
|
else if (obj->type == OBJ_TAG)
|
||||||
release_tag_memory((struct tag*)obj);
|
release_tag_memory((struct tag*)obj);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue