
Dear list members, This is my first attempt to create a FFI to libevent (http://monkey.org/~provos/libevent/) which is an event notification library. A simple usage example is for instance given here: http://unx.ca/log/libevent_echosrv1c/ . In C one basically creates struct event instances which are initialized with a callback function and the kind of event (e.g. read) one is intested in. Optionally a data argument can be given which will be passed to the callback function when invoked eventually. An event dispatcher loop will invoke the callback when the event occurs. I have attached my first attempt at a FFI to libevent. However it doesn't work correctly. In the client code I want to pass 99 as data to the callback function, but what is printed out is 0. I guess there is an issue with pointer derefencing, but I don't know. Also I am not sure how to handle the FunPtr deallocation. Since the FunPtr is stored in the foreign event structure I don't know when I can free it. I would be grateful for any advices, hints or comments. And I really look forward to the FFI section in the "Real World Haskell" book. Thank you very much. - Levi