summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2018-02-08 11:14:30 +0000
committerPatrick Steinhardt <ps@pks.im>2018-06-10 19:30:40 +0200
commit56ffdfc61e37b9e7634c7c73b05d84355bea61cd (patch)
tree007355c24af97e140db54b954ba10a6e916757c3
parent396e49600c2131b5727d07f06fb28ba3c0c73923 (diff)
downloadlibgit2-56ffdfc61e37b9e7634c7c73b05d84355bea61cd.tar.gz
buffer: deprecate `git_buf_free` in favor of `git_buf_dispose`
-rw-r--r--include/git2/buffer.h14
-rw-r--r--src/buffer.c7
2 files changed, 19 insertions, 2 deletions
diff --git a/include/git2/buffer.h b/include/git2/buffer.h
index 9fc6a5805..41cd126b3 100644
--- a/include/git2/buffer.h
+++ b/include/git2/buffer.h
@@ -69,7 +69,19 @@ typedef struct {
*
* @param buffer The buffer to deallocate
*/
-GIT_EXTERN(void) git_buf_free(git_buf *buffer);
+GIT_EXTERN(void) git_buf_dispose(git_buf *buffer);
+
+/**
+ * Alias of `git_buf_dispose`.
+ *
+ * This function is directly calls `git_buf_dispose` now and is deprecated.
+ * Going forward, we refer to functions freeing the internal state of a
+ * structure a `dispose` function, while functions freeing the structure
+ * themselves will be called a `free` function.
+ *
+ * This function is going to be removed in v0.30.0.
+ */
+GIT_EXTERN(void) GIT_DEPRECATED(git_buf_free)(git_buf *buffer);
/**
* Resize the buffer allocation to make more space.
diff --git a/src/buffer.c b/src/buffer.c
index 8a58d1afa..c94ce5d1b 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -116,7 +116,7 @@ int git_buf_grow_by(git_buf *buffer, size_t additional_size)
return git_buf_try_grow(buffer, newsize, true);
}
-void git_buf_free(git_buf *buf)
+void git_buf_dispose(git_buf *buf)
{
if (!buf) return;
@@ -126,6 +126,11 @@ void git_buf_free(git_buf *buf)
git_buf_init(buf, 0);
}
+void git_buf_free(git_buf *buf)
+{
+ git_buf_dispose(buf);
+}
+
void git_buf_sanitize(git_buf *buf)
{
if (buf->ptr == NULL) {