• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to overload system 'malloc'?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >How to overload system 'malloc'? (From: Yuri <email@hidden>)

  • Prev by Date: How to overload system 'malloc'?
  • Next by Date: Re: How to overload system 'malloc'?
  • Previous by thread: How to overload system 'malloc'?
  • Next by thread: Re: How to overload system 'malloc'?
  • Index(es):
    • Date
    • Thread