public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* How to tell compiler to use my_malloc inplace of normal 'malloc'
@ 2001-08-22 14:42 Mynampati, Venkata S.
  2001-08-22 15:12 ` Ryan T. Sammartino
  2001-08-23 23:39 ` Alexandre Oliva
  0 siblings, 2 replies; 7+ messages in thread
From: Mynampati, Venkata S. @ 2001-08-22 14:42 UTC (permalink / raw)
  To: 'gcc-help@gcc.gnu.org'

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.
  

^ permalink raw reply	[flat|nested] 7+ messages in thread
* RE: How to tell compiler to use my_malloc inplace of normal 'malloc'
@ 2001-08-23  7:45 Mynampati, Venkata S.
  2001-08-23  8:38 ` John Love-Jensen
  0 siblings, 1 reply; 7+ messages in thread
From: Mynampati, Venkata S. @ 2001-08-23  7:45 UTC (permalink / raw)
  To: 'Ryan T. Sammartino'; +Cc: 'gcc-help@gcc.gnu.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 

^ permalink raw reply	[flat|nested] 7+ messages in thread
* Re: How to tell compiler to use my_malloc inplace of normal 'malloc'
@ 2001-08-23  8:04 Mirko Vogel
  2001-08-23  8:26 ` John Love-Jensen
  0 siblings, 1 reply; 7+ messages in thread
From: Mirko Vogel @ 2001-08-23  8:04 UTC (permalink / raw)
  To: gcc-help

Hello,

why don't you compile the files you want to use my_alloc
with -Dmalloc=my_malloc and the rest without:

gcc -c file1.c file2.c -Dmalloc=my_malloc
gcc -c my_alloc.c
gcc file1.o file2.o my_alloc.o

You said, you just want to replace the malloc-*calls*, so I assume, the
string "alloc" appears otherwise, too. Perhaps -Dmalloc(=my_malloc( will
work?

But thats a really ugly solution...

Mirko Vogel



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2001-08-23 23:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-22 14:42 How to tell compiler to use my_malloc inplace of normal 'malloc' Mynampati, Venkata S.
2001-08-22 15:12 ` Ryan T. Sammartino
2001-08-23 23:39 ` Alexandre Oliva
2001-08-23  7:45 Mynampati, Venkata S.
2001-08-23  8:38 ` John Love-Jensen
2001-08-23  8:04 Mirko Vogel
2001-08-23  8:26 ` John Love-Jensen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).