Skip to content

Commit 56ffdfc

Browse files
committed
buffer: deprecate git_buf_free in favor of git_buf_dispose
1 parent 396e496 commit 56ffdfc

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

include/git2/buffer.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,19 @@ typedef struct {
6969
*
7070
* @param buffer The buffer to deallocate
7171
*/
72-
GIT_EXTERN(void) git_buf_free(git_buf *buffer);
72+
GIT_EXTERN(void) git_buf_dispose(git_buf *buffer);
73+
74+
/**
75+
* Alias of `git_buf_dispose`.
76+
*
77+
* This function is directly calls `git_buf_dispose` now and is deprecated.
78+
* Going forward, we refer to functions freeing the internal state of a
79+
* structure a `dispose` function, while functions freeing the structure
80+
* themselves will be called a `free` function.
81+
*
82+
* This function is going to be removed in v0.30.0.
83+
*/
84+
GIT_EXTERN(void) GIT_DEPRECATED(git_buf_free)(git_buf *buffer);
7385

7486
/**
7587
* Resize the buffer allocation to make more space.

src/buffer.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ int git_buf_grow_by(git_buf *buffer, size_t additional_size)
116116
return git_buf_try_grow(buffer, newsize, true);
117117
}
118118

119-
void git_buf_free(git_buf *buf)
119+
void git_buf_dispose(git_buf *buf)
120120
{
121121
if (!buf) return;
122122

@@ -126,6 +126,11 @@ void git_buf_free(git_buf *buf)
126126
git_buf_init(buf, 0);
127127
}
128128

129+
void git_buf_free(git_buf *buf)
130+
{
131+
git_buf_dispose(buf);
132+
}
133+
129134
void git_buf_sanitize(git_buf *buf)
130135
{
131136
if (buf->ptr == NULL) {

0 commit comments

Comments
 (0)