aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2011-08-23 21:43:06 +0200
committerAndreas Schneider <asn@cryptomilk.org>2011-08-23 21:52:21 +0200
commitfa4378d47ec4a2dfa54e773ab83643a9645eccad (patch)
treee55ab067226b8cc1268c42d1abe9f46f29b84b65
parente94b0f8c08af8b2cb19b8666fd3bdcb767f62c53 (diff)
downloadlibssh-fa4378d47ec4a2dfa54e773ab83643a9645eccad.tar.gz
libssh-fa4378d47ec4a2dfa54e773ab83643a9645eccad.tar.xz
libssh-fa4378d47ec4a2dfa54e773ab83643a9645eccad.zip
poll: Just make the code a bit more readable.
Maybe this fixes a cppcheck false positive. (cherry picked from commit 45c1a23769b63e72e895158bcab83aad31d483dd)
-rw-r--r--src/poll.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/poll.c b/src/poll.c
index 2b3c5ba2..4fb63ad8 100644
--- a/src/poll.c
+++ b/src/poll.c
@@ -745,7 +745,8 @@ int ssh_event_add_fd(ssh_event event, socket_t fd, short events,
pw->cb = cb;
pw->userdata = userdata;
-
+
+ /* pw is freed by ssh_event_remove_fd */
p = ssh_poll_new(fd, events, ssh_event_fd_wrapper_callback, pw);
if(p == NULL) {
free(pw);
@@ -838,7 +839,6 @@ int ssh_event_dopoll(ssh_event event, int timeout) {
* SSH_ERROR on failure
*/
int ssh_event_remove_fd(ssh_event event, socket_t fd) {
- ssh_poll_handle p;
register size_t i, used;
int rc = SSH_ERROR;
@@ -849,9 +849,11 @@ int ssh_event_remove_fd(ssh_event event, socket_t fd) {
used = event->ctx->polls_used;
for (i = 0; i < used; i++) {
if(fd == event->ctx->pollfds[i].fd) {
- p = event->ctx->pollptrs[i];
+ ssh_poll_handle p = event->ctx->pollptrs[i];
+ struct ssh_event_fd_wrapper *pw = p->cb_data;
+
ssh_poll_ctx_remove(event->ctx, p);
- free(p->cb_data);
+ free(pw);
ssh_poll_free(p);
rc = SSH_OK;
/* restart the loop */