This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


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

Re: How to tell compiler to use my_malloc inplace of normal 'malloc'


On Aug 22, 2001, "Mynampati, Venkata S." <MynamVS@nsc-msg01.network.com> wrote:

> I read that while compiling i can tell the compiler to replace all mallocs
> with my wrapper function called 'my_malloc', in which, i do something
> and call malloc.

You can do this if you're using the GNU linker: it accepts
-wrap=malloc, so you define _wrap_malloc and call _real_malloc() in it
whenever you mean to call the actual malloc.  Of course, you only use
this at link time.

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist    *Please* write to mailing lists, not to me


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