commit: prepare repo_unuse_commit_buffer to handle any repo
authorStefan Beller <sbeller@google.com>
Wed, 14 Nov 2018 00:12:58 +0000 (16:12 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 14 Nov 2018 08:22:40 +0000 (17:22 +0900)
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
commit.c
commit.h
contrib/coccinelle/the_repository.pending.cocci
index 4034def16c7680bafcb6364298112f7ff459c819..7d2f3a9a934ed3fe092811265b468999a459e32c 100644 (file)
--- a/commit.c
+++ b/commit.c
@@ -318,10 +318,12 @@ const void *repo_get_commit_buffer(struct repository *r,
        return ret;
 }
 
-void unuse_commit_buffer(const struct commit *commit, const void *buffer)
+void repo_unuse_commit_buffer(struct repository *r,
+                             const struct commit *commit,
+                             const void *buffer)
 {
        struct commit_buffer *v = buffer_slab_peek(
-               the_repository->parsed_objects->buffer_slab, commit);
+               r->parsed_objects->buffer_slab, commit);
        if (!(v && v->buffer == buffer))
                free((void *)buffer);
 }
index 591a77a5bbd1ce440080b91c6b39d76b88cedd1e..57375e3239c3b2e2a1614b40d8cf8640f5318d92 100644 (file)
--- a/commit.h
+++ b/commit.h
@@ -130,7 +130,12 @@ const void *repo_get_commit_buffer(struct repository *r,
  * from an earlier call to get_commit_buffer.  The buffer may or may not be
  * freed by this call; callers should not access the memory afterwards.
  */
-void unuse_commit_buffer(const struct commit *, const void *buffer);
+void repo_unuse_commit_buffer(struct repository *r,
+                             const struct commit *,
+                             const void *buffer);
+#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
+#define unuse_commit_buffer(c, b) repo_unuse_commit_buffer(the_repository, c, b)
+#endif
 
 /*
  * Free any cached object buffer associated with the commit.
index 4018e6eaf71ee901ce516d8bea6fdabbd865eab4..516f19ffeee3028c733895c859c5b252c8c8eff9 100644 (file)
@@ -115,3 +115,11 @@ expression F;
 - get_commit_buffer(
 + repo_get_commit_buffer(the_repository,
   E, F);
+
+@@
+expression E;
+expression F;
+@@
+- unuse_commit_buffer(
++ repo_unuse_commit_buffer(the_repository,
+  E, F);