diff options
author | milo <milo@r0ot.me> | 2011-02-20 13:53:53 +0100 |
---|---|---|
committer | milo <milo@r0ot.me> | 2011-02-20 14:35:11 +0100 |
commit | 4ee4450a6b37a099a067f6e1e9a61f566cce9247 (patch) | |
tree | be9af7bccfb3a5bb0d77ededc49396872050c22a | |
parent | a2634ceea8e121f141ecf6e283a04a9926933cc1 (diff) | |
download | libssh-4ee4450a6b37a099a067f6e1e9a61f566cce9247.tar.gz libssh-4ee4450a6b37a099a067f6e1e9a61f566cce9247.tar.xz libssh-4ee4450a6b37a099a067f6e1e9a61f566cce9247.zip |
poll: Added a function to free an event.
-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 1062ba5a..3fc7b6c6 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: */ |