diff options
| author | Patrick Steinhardt <ps@pks.im> | 2017-06-07 09:56:31 +0200 |
|---|---|---|
| committer | Patrick Steinhardt <ps@pks.im> | 2017-06-08 11:58:22 +0200 |
| commit | 4796c916d376af528d8bbf07e8a5e176da6ee928 (patch) | |
| tree | 0084d43114a42165f68a8bc6bed09b17aa60d6d9 /src/buffer.h | |
| parent | 9a8386a2c649fa74cf90fe95931bc3fc0466f2f6 (diff) | |
| download | libgit2-4796c916d376af528d8bbf07e8a5e176da6ee928.tar.gz | |
buffer: return errors for `git_buf_init` and `git_buf_attach`
Both the `git_buf_init` and `git_buf_attach` functions may call
`git_buf_grow` in case they were given an allocation length as
parameter. As such, it is possible for these functions to fail when we
run out of memory. While it won't probably be used anytime soon, it does
indeed make sense to also record this fact by returning an error code
from both functions. As they belong to the internal API only, this
change does not break our interface.
Diffstat (limited to 'src/buffer.h')
| -rw-r--r-- | src/buffer.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/buffer.h b/src/buffer.h index a76b2d771..b0aece488 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -34,7 +34,7 @@ GIT_INLINE(bool) git_buf_is_allocated(const git_buf *buf) * For the cases where GIT_BUF_INIT cannot be used to do static * initialization. */ -extern void git_buf_init(git_buf *buf, size_t initial_size); +extern int git_buf_init(git_buf *buf, size_t initial_size); /** * Resize the buffer allocation to make more space. @@ -73,7 +73,7 @@ extern void git_buf_sanitize(git_buf *buf); extern void git_buf_swap(git_buf *buf_a, git_buf *buf_b); extern char *git_buf_detach(git_buf *buf); -extern void git_buf_attach(git_buf *buf, char *ptr, size_t asize); +extern int git_buf_attach(git_buf *buf, char *ptr, size_t asize); /* Populates a `git_buf` where the contents are not "owned" by the * buffer, and calls to `git_buf_free` will not free the given buf. |
