mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-08-10 06:23:01 +03:00
poll: Added a function to free an event.
This commit is contained in:
@@ -476,6 +476,7 @@ LIBSSH_API int ssh_getpass(const char *prompt, char *buf, size_t len, int echo,
|
|||||||
int verify);
|
int verify);
|
||||||
|
|
||||||
LIBSSH_API ssh_event ssh_event_new(void);
|
LIBSSH_API ssh_event ssh_event_new(void);
|
||||||
|
LIBSSH_API void ssh_event_free(ssh_event event);
|
||||||
|
|
||||||
#ifndef LIBSSH_LEGACY_0_4
|
#ifndef LIBSSH_LEGACY_0_4
|
||||||
#include "libssh/legacy.h"
|
#include "libssh/legacy.h"
|
||||||
|
23
src/poll.c
23
src/poll.c
@@ -727,6 +727,29 @@ ssh_event ssh_event_new(void) {
|
|||||||
return event;
|
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: */
|
/* vim: set ts=4 sw=4 et cindent: */
|
||||||
|
Reference in New Issue
Block a user