AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2013.05.21 10:32 "[Tiff] memory management function calls", by Chris Liddell
2013.05.21 14:11 "Re: [Tiff] memory management function calls", by Bob Friesenhahn
2013.05.21 15:11 "Re: [Tiff] memory management function calls", by Chris Liddell
2013.05.21 15:18 "Re: [Tiff] memory management function calls", by Bob Friesenhahn
2013.05.21 15:32 "Re: [Tiff] memory management function calls", by Chris Liddell
2013.05.21 15:38 "Re: [Tiff] memory management function calls", by Bob Friesenhahn
2013.05.21 17:21 "Re: [Tiff] memory management function calls", by Joris Van Damme
2013.05.21 17:28 "Re: [Tiff] memory management function calls", by Chris Liddell

2013.05.21 15:38 "Re: [Tiff] memory management function calls", by Bob Friesenhahn

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, but the default functions (which would be used by existing callers, and callers not requiring to the hook the memory calls) would simply ignore that parameter.

Rather than debate the ephemeral ad nauseum, I'll put together patch over the next week or so between my other tasks, and post it so there's something concrete to critique. I just wanted to check there would be some interest in it before I devoted the time to it.

Make sure to consider that libtiff uses other libraries which have their own allocation policies. There may be an implicit assumption that all allocated buffers are allocated by libc "malloc" and that it is ok to pass a buffer allocation from one library to another and that the recipient library can free the buffer using free(). Dealing with multiple allocators in such code can be challenging. I don't know if such cases currently exist but it needs to be considered.

Bob
--
Bob Friesenhahn
bfriesen@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer, http://www.GraphicsMagick.org/