… | |
… | |
2881 | callback, free it. Also, use no error checking, as usual. |
2881 | callback, free it. Also, use no error checking, as usual. |
2882 | |
2882 | |
2883 | static void |
2883 | static void |
2884 | idle_cb (struct ev_loop *loop, ev_idle *w, int revents) |
2884 | idle_cb (struct ev_loop *loop, ev_idle *w, int revents) |
2885 | { |
2885 | { |
|
|
2886 | // stop the watcher |
|
|
2887 | ev_idle_stop (loop, w); |
|
|
2888 | |
|
|
2889 | // now we can free it |
2886 | free (w); |
2890 | free (w); |
|
|
2891 | |
2887 | // now do something you wanted to do when the program has |
2892 | // now do something you wanted to do when the program has |
2888 | // no longer anything immediate to do. |
2893 | // no longer anything immediate to do. |
2889 | } |
2894 | } |
2890 | |
2895 | |
2891 | ev_idle *idle_watcher = malloc (sizeof (ev_idle)); |
2896 | ev_idle *idle_watcher = malloc (sizeof (ev_idle)); |