diff options
-rw-r--r-- | include/libssh/libssh.h | 1 | ||||
-rw-r--r-- | src/poll.c | 23 |
2 files changed, 24 insertions, 0 deletions
diff --git a/include/libssh/libssh.h b/include/libssh/libssh.h index 1062ba5..3fc7b6c 100644 --- a/include/libssh/libssh.h +++ b/include/libssh/libssh.h @@ -476,6 +476,7 @@ LIBSSH_API int ssh_getpass(const char *prompt, char *buf, size_t len, int echo, int verify); LIBSSH_API ssh_event ssh_event_new(void); +LIBSSH_API void ssh_event_free(ssh_event event); #ifndef LIBSSH_LEGACY_0_4 #include "libssh/legacy.h" @@ -727,6 +727,29 @@ ssh_event ssh_event_new(void) { return event; } +/** + * @brief Free an event context. + * + * @param event The ssh_event object to free. + * Note: you have to manually remove sessions and socket + * fds before freeing the event object. + * + */ +void ssh_event_free(ssh_event event) { + if(event == NULL) { + return; + } + if(event->ctx != NULL) { + ssh_poll_ctx_free(event->ctx); + } +#ifdef WITH_SERVER + if(event->sessions != NULL) { + ssh_list_free(event->sessions); + } +#endif + free(event); +} + /** @} */ /* vim: set ts=4 sw=4 et cindent: */ |