From 013203301f3a5d6e6269595bd8b6b05507f6d53c Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Sun, 2 Sep 2018 09:54:20 +0200 Subject: [PATCH] include: Add SSH_STRING_FREE() and SSH_STRING_FREE_CHAR() Signed-off-by: Andreas Schneider (cherry picked from commit 3efc64112addad19f3e4e9cc9a53fbf96f1bf4a2) --- include/libssh/libssh.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/libssh/libssh.h b/include/libssh/libssh.h index e5830957..fa5683a3 100644 --- a/include/libssh/libssh.h +++ b/include/libssh/libssh.h @@ -757,12 +757,16 @@ LIBSSH_API void ssh_string_burn(ssh_string str); LIBSSH_API ssh_string ssh_string_copy(ssh_string str); LIBSSH_API void *ssh_string_data(ssh_string str); LIBSSH_API int ssh_string_fill(ssh_string str, const void *data, size_t len); +#define SSH_STRING_FREE(x) \ + do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0) LIBSSH_API void ssh_string_free(ssh_string str); LIBSSH_API ssh_string ssh_string_from_char(const char *what); LIBSSH_API size_t ssh_string_len(ssh_string str); LIBSSH_API ssh_string ssh_string_new(size_t size); LIBSSH_API const char *ssh_string_get_char(ssh_string str); LIBSSH_API char *ssh_string_to_char(ssh_string str); +#define SSH_STRING_FREE_CHAR(x) \ + do { if ((x) != NULL) { ssh_string_free_char(x); x = NULL; } } while(0) LIBSSH_API void ssh_string_free_char(char *s); LIBSSH_API int ssh_getpass(const char *prompt, char *buf, size_t len, int echo,