2013.05.21 17:21 "Re: [Tiff] memory management function calls", by Joris Van Damme
Yes, but then standard malloc/realloc/free type functions can not be specified directly. Special wrapper functions would need to be added in order to support passing (and ignoring) the context before calling such functions.
Sure, so the function pointer types for the callbacks would have
> some kind of context pointer parameter
I've had the same problem when I added the context parameter to warning/error handler callbacks.
My solution was to support two sets of callbacks. One was the traditional set, without the context cookie parameter, the other was the new set with the additional parameter. The single point in the LibTiff library where the callback is actually called, it used the new callback with additional parameter if that callback is set. Otherwise, it calls the traditional handler without the additional context.
This way both needs are satisfied, people who require a context parameter set the new set of callbacks, people who require existing code to remain working without code change automatically stick with the old callbacks. It's a bit crufty and far fetched, but it does solve the problem. The only real disadvantage is that people hardly notice the option of using the new callbacks, so they kind of get forgotten and they may not work anymore a couple of versions down the line.
Joris Van Damme