This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
RE: How to tell compiler to use my_malloc inplace of normal 'malloc'
- To: "'Ryan T. Sammartino'" <ryants at home dot com>
- Subject: RE: How to tell compiler to use my_malloc inplace of normal 'malloc'
- From: "Mynampati, Venkata S." <MynamVS at nsc-msg01 dot network dot com>
- Date: Thu, 23 Aug 2001 09:45:40 -0500
- Cc: "'gcc-help at gcc dot gnu dot org'" <gcc-help at gcc dot gnu dot org>
>
>
>
> #define malloc my_malloc
If i use this, then where ever i use malloc, it gets
replaced by my_malloc.
what i want is this:
my_malloc()
{
/* do my own stuff */
malloc();
}
and i want my_malloc to be substituted in place of all malloc
calls.
I am thinking that this could be done without changing all the
files, except for Makefiles.
Can i do this or is my understanding is wrong.
> or, on the command-line, gcc ... "-Dmalloc=my_malloc"
>
>
>
> * Mynampati, Venkata S. <MynamVS@nsc-msg01.network.com>
> [22/08/2001 14:43]:
> > Hi,
> > My question is a bit confusing, but it pertains to what i
> read sometime
> > back, which is like this:
> > 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. I remember reading that i can use this
> facility to keep
> > track of whose using malloc and how many number of times.
> > i.e where ever 'malloc' is used, 'my_malloc' gets substituted.
> >
> > Could you helping me how to achieve this using gcc?
> > [or may be i dreamt up this one]
> >
> > Best Regards
> > Venkat
> >
> >
> > Worry about chances you miss when you don't even try.
> >
> >
>
> --
> Ryan T. Sammartino
> http://members.home.net/ryants/
> To communicate is the beginning of understanding.
> -- AT&T
Thanks and regards,
Venkat