eloop: add ev_fd_is_bound() helper
authorDavid Herrmann <dh.herrmann@googlemail.com>
Thu, 17 May 2012 14:33:47 +0000 (16:33 +0200)
committerDavid Herrmann <dh.herrmann@googlemail.com>
Thu, 17 May 2012 14:33:47 +0000 (16:33 +0200)
This helper returns true if the fd is bound to an eloop object, otherwise
false is returned.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
src/eloop.c
src/eloop.h

index 84468da..60e8a9a 100644 (file)
@@ -321,6 +321,11 @@ void ev_fd_unref(struct ev_fd *fd)
        free(fd);
 }
 
+bool ev_fd_is_bound(struct ev_fd *fd)
+{
+       return fd && fd->loop;
+}
+
 int ev_eloop_new_fd(struct ev_eloop *loop, struct ev_fd **out, int rfd,
                        int mask, ev_fd_cb cb, void *data)
 {
index 0eef7e1..95f7410 100644 (file)
@@ -35,6 +35,7 @@
 #define EV_ELOOP_H
 
 #include <inttypes.h>
+#include <stdbool.h>
 #include <stdlib.h>
 #include <sys/signalfd.h>
 #include <time.h>
@@ -90,6 +91,7 @@ void ev_eloop_rm_idle(struct ev_idle *idle);
 int ev_fd_new(struct ev_fd **out);
 void ev_fd_ref(struct ev_fd *fd);
 void ev_fd_unref(struct ev_fd *fd);
+bool ev_fd_is_bound(struct ev_fd *fd);
 
 int ev_eloop_new_fd(struct ev_eloop *loop, struct ev_fd **out, int rfd,
                        int mask, ev_fd_cb cb, void *data);