Hey Jafar,

The "data" member is used to pass additional information around with a watcher, 
it's typed void * and you ought to cast your int to intptr_t, but it does not 
sound like a good solution to me.

I would create a struct, allocate it in the appropriate place and point data 
member to this struct. Other choice is to embed the watcher into another 
structure (which would contain your int and whatever else you would need) and 
use container_of magic (refer to Linux kernel source for implementation or rock 
your own using offsetof) to retrieve a pointer to your structure. The latter is 
more preferable as it enables you to allocate your watcher and auxiliary data 
in one go. Also this approach is type-safe (at least better than casting void * 
to something or interpreting it as an integer).

--
Konstantin Olkhovskiy

02.07.2013, в 19:35, Jafar habibi livar <[email protected]> написал(а):

> hello
> 
> first of I should thanks for developers of libev.
> heres my question
> what is data member in struct ev_timer?
> can we use it to pass some data to ev_timer callback function?
> I tried but I couldnt save a int variable in data member and get it back in 
> callback function
> I would be very grateful if someone answer me.
> 
> thanks
> _______________________________________________
> libev mailing list
> [email protected]
> http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev

_______________________________________________
libev mailing list
[email protected]
http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev
  • ev_timer Jafar habibi livar
    • Re: ev_timer Konstantin Olkhovskiy

Reply via email to