summaryrefslogtreecommitdiff
path: root/src/buffer.h
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2015-02-10 23:55:07 -0500
committerEdward Thomson <ethomson@edwardthomson.com>2015-02-12 22:54:47 -0500
commit4aa664ae3953d99c2ae4cd769f02818bc122eebc (patch)
tree7316e3d7febcbcde19dd4844af9503f4c6d57d69 /src/buffer.h
parent3603cb0978b7ef21ff9cd63693ebd6d27bc2bc53 (diff)
downloadlibgit2-4aa664ae3953d99c2ae4cd769f02818bc122eebc.tar.gz
git_buf_grow_by: increase buf asize incrementally
Introduce `git_buf_grow_by` to incrementally increase the size of a `git_buf`, performing an overflow calculation on the growth.
Diffstat (limited to 'src/buffer.h')
-rw-r--r--src/buffer.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/buffer.h b/src/buffer.h
index 8ee4b532c..52342e309 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -37,6 +37,18 @@ GIT_INLINE(bool) git_buf_is_allocated(const git_buf *buf)
extern void git_buf_init(git_buf *buf, size_t initial_size);
/**
+ * Resize the buffer allocation to make more space.
+ *
+ * This will attempt to grow the buffer to accommodate the additional size.
+ * It is similar to `git_buf_grow`, but performs the new size calculation,
+ * checking for overflow.
+ *
+ * Like `git_buf_grow`, if this is a user-supplied buffer, this will allocate
+ * a new buffer.
+ */
+extern int git_buf_grow_by(git_buf *buffer, size_t additional_size);
+
+/**
* Attempt to grow the buffer to hold at least `target_size` bytes.
*
* If the allocation fails, this will return an error. If `mark_oom` is true,