Suggestion for libev man page

Marc Lehmann schmorp at schmorp.de
Sat Jan 14 17:59:13 CET 2017


On Fri, Jan 13, 2017 at 07:49:14PM +0000, "MONGIOVI, ROY" <rx5330 at att.com> wrote:
> 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.

Something being obscure to you is, unfortunately, not a good reason
to change things - libev *is* a pretty low level C library, and good
knowledge of C is required. The libev manpage should be a lot of things,
but not a basic C tutorial.

More importantly, why would it be fragile to changes in the containing
structure?

Lastly, the subject of your mail, says there is a suggestion, but in the
body you don't seem to have a suggestion - what is it that you suggest.

> 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

Yes, this is actually explained in the very section you talk about. What
about it did you find lacking, if anything?

> That's much clearer than offsetof.

That's your (valid) opinion, and in fact, the documentation documents this
as a valid option. It is not the only option, however, and some people
are concerned more about the extra speed than some specific sense of
aesthetics. That's why both ways are supported and documented.

Greetings,

-- 
                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_              http://www.deliantra.net
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      schmorp at schmorp.de
      -=====/_/_//_/\_,_/ /_/\_\



More information about the libev mailing list