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. --- include/git2/deprecated.h | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'include/git2/deprecated.h') diff --git a/include/git2/deprecated.h b/include/git2/deprecated.h index 7be6bb258..9fd4489a9 100644 --- a/include/git2/deprecated.h +++ b/include/git2/deprecated.h @@ -11,7 +11,6 @@ #include "config.h" #include "common.h" #include "blame.h" -#include "buffer.h" #include "checkout.h" #include "cherrypick.h" #include "clone.h" @@ -123,17 +122,23 @@ GIT_EXTERN(int) git_blob_filtered_content( */ /**@{*/ -/** - * Free the memory referred to by the git_buf. This is an alias of - * `git_buf_dispose` and is preserved for backward compatibility. - * - * This function is deprecated, but there is no plan to remove this - * function at this time. - * - * @deprecated Use git_buf_dispose - * @see git_buf_dispose +/* + * You may hard-deprecate only the git_buf compatibility layer by + * setting GIT_DEPRECATE_BUF. */ -GIT_EXTERN(void) git_buf_free(git_buf *buffer); +#ifndef GIT_DEPRECATE_BUF + +typedef git_userbuf git_buf; + +#define GIT_BUF_INIT_CONST(str, len) GIT_USERBUF_CONST(str, len) +#define git_buf_set(buf, data, datalen) git_userbuf_set(buf, data, datalen) +#define git_buf_grow(buf, size) git_userbuf_grow(buf, size) +#define git_buf_is_binary(b) git_userbuf_is_binary(b) +#define git_buf_contains_nul(b) git_userbuf_contains_nul(b) +#define git_buf_dispose(b) git_userbuf_dispose(b) +#define git_buf_free(b) git_userbuf_dispose(b) + +#endif /* GIT_DEPRECATE_BUF */ /**@}*/ -- cgit v1.2.1