From bab51e2de6879767bea2fe2a5d1f5f44a1568f51 Mon Sep 17 00:00:00 2001 From: Edward Thomson Date: Thu, 28 May 2020 10:07:36 +0100 Subject: buf: deprecate git_buf as a public type The `git_buf` type is now no longer a publicly available structure, and the `git_buf` family of functions are no longer exported. The deprecation layer adds a typedef for `git_buf` (as `git_userbuf`) and macros that define `git_buf` functions as `git_userbuf` functions. This provides API (but not ABI) compatibility with libgit2 1.0's buffer functionality. Within libgit2 itself, we take care to avoid including those deprecated typedefs and macros, since we want to continue using the `git_buf` type and functions unmodified. Therefore, a `GIT_DEPRECATE_BUF` guard now wraps the buffer deprecation layer. libgit2 will define that. --- src/userbuf.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'src/userbuf.c') diff --git a/src/userbuf.c b/src/userbuf.c index e5c8fa3b7..5bfb27ae0 100644 --- a/src/userbuf.c +++ b/src/userbuf.c @@ -4,9 +4,9 @@ * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ + #include "userbuf.h" #include "buffer.h" -#include "git2/buffer.h" #include "buf_text.h" #include @@ -21,11 +21,26 @@ void git_userbuf_sanitize(git_userbuf *buf) } } -int git_userbuf_set(git_userbuf *buf, const char *ptr, size_t len) +int git_userbuf_is_binary(const git_userbuf *buf) +{ + return git_buf_text_is_binary((git_buf *)buf); +} + +int git_userbuf_contains_nul(const git_userbuf *buf) +{ + return git_buf_text_contains_nul((git_buf *)buf); +} + +int git_userbuf_set(git_userbuf *buf, const void *ptr, size_t len) { return git_buf_set((git_buf *)buf, ptr, len); } +int git_userbuf_grow(git_userbuf *buf, size_t size) +{ + return git_buf_grow((git_buf *)buf, size); +} + void git_userbuf_dispose(git_userbuf *buf) { git_buf_dispose((git_buf *)buf); -- cgit v1.2.1