In the section titled "Building your own composite watchers" the man page 
suggests putting several watchers in a single structure and then using offsetof 
within each watcher to compute back to the beginning of the containing 
structure.  That seems overly obscure to me, not to mention that it makes the 
code extremely fragile to changes in the containing structure.  I think that 
this is an unnecessary complication.

Each watcher already has a void *data variable allocated which in this example 
is unused.  Just store a pointer to the containing structure in each watcher's 
data variable.  Then cast the data pointer to the containing structure type 
exactly as is done with the watcher pointer in the previous section 
"Associating custom data with a watcher."  That's much clearer than offsetof.
Roy
_______________________________________________
libev mailing list
[email protected]
http://lists.schmorp.de/mailman/listinfo/libev

Reply via email to