This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Override fscanf memory allocation function?


On Tue, Jan 14, 2014 at 10:06:54AM -0600, Ian Pilcher wrote:
> Is it possible to override the memory allocation function used by scanf
> and friends when the 'm' flag is used with a string conversion?
> 
> I am writing a library, and I would like to allow the application to
> specify the memory management functions used by the library.
> 
> My library uses fscanf to read files line-by-line:
> 
>   fscanf(in, "%m[^\n]", &line)
> 
> Thanks!
> 
Not directly, there is a solution that is overkill, override a
malloc by a LD_PRELOADED library then use backtrace to check if
a malloc was called from fscanf and call appropriate function if so.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]