Add a repository argument to allow callers of free_commit_buffer to be more specific about which repository to handle. This is a small mechanical change; it doesn't change the implementation to handle repositories other than the_repository yet. As with the previous commits, use a macro to catch callers passing a repository other than the_repository at compile time. Signed-off-by: Stefan Beller <sbeller@xxxxxxxxxx> --- builtin/fsck.c | 2 +- builtin/log.c | 4 ++-- builtin/rev-list.c | 2 +- commit.c | 2 +- commit.h | 3 ++- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/builtin/fsck.c b/builtin/fsck.c index 2e8b298384..01c612f75f 100644 --- a/builtin/fsck.c +++ b/builtin/fsck.c @@ -365,7 +365,7 @@ static int fsck_obj(struct object *obj) if (obj->type == OBJ_TREE) free_tree_buffer((struct tree *)obj); if (obj->type == OBJ_COMMIT) - free_commit_buffer((struct commit *)obj); + free_commit_buffer(the_repository, (struct commit *)obj); return err; } diff --git a/builtin/log.c b/builtin/log.c index 7080c5f776..12426e685f 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -386,7 +386,7 @@ static int cmd_log_walk(struct rev_info *rev) * We may show a given commit multiple times when * walking the reflogs. */ - free_commit_buffer(commit); + free_commit_buffer(the_repository, commit); free_commit_list(commit->parents); commit->parents = NULL; } @@ -1813,7 +1813,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) open_next_file(rev.numbered_files ? NULL : commit, NULL, &rev, quiet)) die(_("Failed to create output files")); shown = log_tree_commit(&rev, commit); - free_commit_buffer(commit); + free_commit_buffer(the_repository, commit); /* We put one extra blank line between formatted * patches and this flag is used by log-tree code diff --git a/builtin/rev-list.c b/builtin/rev-list.c index e28e7426a5..142ba35fdb 100644 --- a/builtin/rev-list.c +++ b/builtin/rev-list.c @@ -193,7 +193,7 @@ static void finish_commit(struct commit *commit, void *data) free_commit_list(commit->parents); commit->parents = NULL; } - free_commit_buffer(commit); + free_commit_buffer(the_repository, commit); } static inline void finish_object__ma(struct object *obj) diff --git a/commit.c b/commit.c index fa578a2d22..8ef8619dec 100644 --- a/commit.c +++ b/commit.c @@ -297,7 +297,7 @@ void unuse_commit_buffer_the_repository(const struct commit *commit, const void free((void *)buffer); } -void free_commit_buffer(struct commit *commit) +void free_commit_buffer_the_repository(struct commit *commit) { struct commit_buffer *v = buffer_slab_peek(&buffer_slab, commit); if (v) { diff --git a/commit.h b/commit.h index 85dd52d1bf..8892989b1d 100644 --- a/commit.h +++ b/commit.h @@ -108,7 +108,8 @@ void unuse_commit_buffer_the_repository(const struct commit *, const void *buffe /* * Free any cached object buffer associated with the commit. */ -void free_commit_buffer(struct commit *); +#define free_commit_buffer(r, c) free_commit_buffer_##r(c) +void free_commit_buffer_the_repository(struct commit *); /* * Disassociate any cached object buffer from the commit, but do not free it. -- 2.15.1.433.g936d1b9894.dirty