How to overload system 'malloc'?
How to overload system 'malloc'?
- Subject: How to overload system 'malloc'?
- From: Yuri <email@hidden>
- Date: Sun, 26 Dec 2010 12:16:00 -0800
I am trying to use strdup/free in the environment where 'malloc' and
'free' are overloaded in dynamic library libtcmalloc_minimal.dylib from
google-perftools macport.
My program brakes with invalid pointer in 'free' since even though
/opt/local/lib/libtcmalloc_minimal.0.dylib is loaded and has 'malloc'
but 'strdup' in
/usr/lib/libSystem.B.dylib still uses and old 'malloc' in libSystem.B.dylib.
Someone previously suggested using -Wl,-bind_at_load in link comamnd,
but it doesn't help.
What is the correct way to completely overload 'malloc'/'free'?
-- tst.C --
#include <string.h>
#include <stdlib.h>
main() {
char *d = strdup("abc");
free(d);
}
-- link command --
g++ -g -o tst tst.C -L/opt/local/lib -ltcmalloc_minimal
--- error from tst ---
src/tcmalloc.cc:372] Attempt to free invalid pointer: 0x1002a0
Abort trap
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden