I have used dlsym()
to invoke my version of malloc, instead of the default library malloc:
lt_malloc = (void*(*)(size_t))dlsym(RTLD_NEXT, "malloc");
TRACE((stderr, "initialize: lt_malloc=%p\n", lt_malloc));
if (!lt_malloc) {
fprintf(stderr, "LeakTracer: could not resolve 'malloc' in 'libc.so': %s\n", dlerror());
exit(1);
}
Now after certain time, may be a timer or so, i want to revert back to the original version of malloc (libc library malloc). How can i do that?
Thanks in advance.