From 8aa808a6001460e656a9e78b31ddb9428ee4a390 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Thu, 4 Apr 2024 18:01:24 +0200 Subject: [PATCH] include: Introduce a SSH_CHANNEL_FREE() macro Signed-off-by: Andreas Schneider --- include/libssh/libssh.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/libssh/libssh.h b/include/libssh/libssh.h index 13f1b812..0f6b6813 100644 --- a/include/libssh/libssh.h +++ b/include/libssh/libssh.h @@ -454,6 +454,13 @@ LIBSSH_API int ssh_blocking_flush(ssh_session session, int timeout); LIBSSH_API ssh_channel ssh_channel_accept_x11(ssh_channel channel, int timeout_ms); LIBSSH_API int ssh_channel_change_pty_size(ssh_channel channel,int cols,int rows); LIBSSH_API int ssh_channel_close(ssh_channel channel); +#define SSH_CHANNEL_FREE(x) \ + do { \ + if ((x) != NULL) { \ + ssh_channel_free(x); \ + (x) = NULL; \ + } \ + } while (0) LIBSSH_API void ssh_channel_free(ssh_channel channel); LIBSSH_API int ssh_channel_get_exit_status(ssh_channel channel); LIBSSH_API ssh_session ssh_channel_get_session(ssh_channel channel);