diff options
author | Edward Thomson <ethomson@microsoft.com> | 2015-02-19 10:05:33 -0500 |
---|---|---|
committer | Edward Thomson <ethomson@microsoft.com> | 2015-02-19 10:05:33 -0500 |
commit | d4cf167515d3ed7b27c1358fc2e19b9caf66e8ad (patch) | |
tree | ecb73c7055ea0a319f72996517f966c904bd5100 /src/buffer.h | |
parent | b49edddcd0af70caee7eb4905dc26199adccabfd (diff) | |
download | libgit2-d4cf167515d3ed7b27c1358fc2e19b9caf66e8ad.tar.gz |
buffer: introduce git_buf_attach_notowned
Provide a convenience function that creates a buffer that can be provided
to callers but will not be freed via `git_buf_free`, so the buffer
creator maintains the allocation lifecycle of the buffer's contents.
Diffstat (limited to 'src/buffer.h')
-rw-r--r-- | src/buffer.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/buffer.h b/src/buffer.h index 52342e309..093ed9b60 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -74,6 +74,12 @@ 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); +/* 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. + */ +extern void git_buf_attach_notowned( + git_buf *buf, const char *ptr, size_t size); + /** * Test if there have been any reallocation failures with this git_buf. * |