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/diff_driver.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/diff_driver.c')
-rw-r--r-- | src/diff_driver.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/diff_driver.c b/src/diff_driver.c index 7313ab573..049e6ef2a 100644 --- a/src/diff_driver.c +++ b/src/diff_driver.c @@ -418,14 +418,13 @@ void git_diff_driver_update_options( int git_diff_driver_content_is_binary( git_diff_driver *driver, const char *content, size_t content_len) { - git_buf search; - - search.ptr = (char *)content; - search.size = min(content_len, GIT_FILTER_BYTES_TO_CHECK_NUL); - search.asize = 0; + git_buf search = GIT_BUF_INIT; GIT_UNUSED(driver); + git_buf_attach_notowned(&search, content, + min(content_len, GIT_FILTER_BYTES_TO_CHECK_NUL)); + /* TODO: provide encoding / binary detection callbacks that can * be UTF-8 aware, etc. For now, instead of trying to be smart, * let's just use the simple NUL-byte detection that core git uses. |