Move a watcher to a different memory location?

Marc Lehmann schmorp at
Sun Nov 17 12:23:53 CET 2013

On Sun, Nov 17, 2013 at 07:12:12PM +0800, Åke Kullenberg <ake.kullenberg at> wrote:
> For example, I allocate memory on the heap for a watcher, but later on I
> want to move the watcher to another place on the heap. I would assume
> libev's internal data structures don't allow for this while the watcher is
> started, but how about when it's stopped? Is this assumption correct? If
> not, how can it be done?

This is indeed not documented either way. I'll discuss this with my
co-designer. In any case, this would indeed only be allowed when they are
not active (e.g. after an explciit ev_xxx_stop).

In the meantime, since watchers have very little state, you could copy
them by calling ev_xxx_init with the values from the old watcher and be
safe no matter how the verdict turns out :)

For example, to copy an I/O watcher, you can do this:

   ev_io_init (&new, ev_cb (&old), old.fd,;

                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_    
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      schmorp at
      -=====/_/_//_/\_,_/ /_/\_\

More information about the libev mailing list