Skip to content

Commit 7031537

Browse files
stefanbellergitster
authored andcommitted
commit: prepare repo_unuse_commit_buffer to handle any repo
Signed-off-by: Stefan Beller <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 07de3fd commit 7031537

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

commit.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,10 +318,12 @@ const void *repo_get_commit_buffer(struct repository *r,
318318
return ret;
319319
}
320320

321-
void unuse_commit_buffer(const struct commit *commit, const void *buffer)
321+
void repo_unuse_commit_buffer(struct repository *r,
322+
const struct commit *commit,
323+
const void *buffer)
322324
{
323325
struct commit_buffer *v = buffer_slab_peek(
324-
the_repository->parsed_objects->buffer_slab, commit);
326+
r->parsed_objects->buffer_slab, commit);
325327
if (!(v && v->buffer == buffer))
326328
free((void *)buffer);
327329
}

commit.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,12 @@ const void *repo_get_commit_buffer(struct repository *r,
130130
* from an earlier call to get_commit_buffer. The buffer may or may not be
131131
* freed by this call; callers should not access the memory afterwards.
132132
*/
133-
void unuse_commit_buffer(const struct commit *, const void *buffer);
133+
void repo_unuse_commit_buffer(struct repository *r,
134+
const struct commit *,
135+
const void *buffer);
136+
#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
137+
#define unuse_commit_buffer(c, b) repo_unuse_commit_buffer(the_repository, c, b)
138+
#endif
134139

135140
/*
136141
* Free any cached object buffer associated with the commit.

contrib/coccinelle/the_repository.pending.cocci

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,11 @@ expression F;
115115
- get_commit_buffer(
116116
+ repo_get_commit_buffer(the_repository,
117117
E, F);
118+
119+
@@
120+
expression E;
121+
expression F;
122+
@@
123+
- unuse_commit_buffer(
124+
+ repo_unuse_commit_buffer(the_repository,
125+
E, F);

0 commit comments

Comments
 (0)