Re: How to overload system 'malloc'?
Re: How to overload system 'malloc'?
- Subject: Re: How to overload system 'malloc'?
- From: Rodrigo Zanatta Silva <email@hidden>
- Date: Mon, 27 Dec 2010 09:25:19 -0200
i don't know a lot of c++, but, you can not use libname::free() ??
2010/12/26 Yuri
<email@hidden>
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
_______________________________________________
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