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/blob.c | |
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/blob.c')
-rw-r--r-- | src/blob.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/blob.c b/src/blob.c index 30d5b705b..ba8769cdc 100644 --- a/src/blob.c +++ b/src/blob.c @@ -329,15 +329,13 @@ cleanup: int git_blob_is_binary(const git_blob *blob) { - git_buf content; + git_buf content = GIT_BUF_INIT; assert(blob); - content.ptr = blob->odb_object->buffer; - content.size = - min(blob->odb_object->cached.size, GIT_FILTER_BYTES_TO_CHECK_NUL); - content.asize = 0; - + git_buf_attach_notowned(&content, blob->odb_object->buffer, + min(blob->odb_object->cached.size, + GIT_FILTER_BYTES_TO_CHECK_NUL)); return git_buf_text_is_binary(&content); } |