This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [RFA] Change malloc to xmalloc - resubmission
- To: "Rudy Folden" <rfolden at redhat dot com>, <gdb-patches at sourceware dot cygnus dot com>
- Subject: Re: [RFA] Change malloc to xmalloc - resubmission
- From: Kevin Buettner <kevinb at cygnus dot com>
- Date: Thu, 25 Jan 2001 09:27:37 -0700
- References: <000d01c086e1$373297c0$3b1110ac@wirespeed.com>
On Jan 25, 9:12am, Rudy Folden wrote:
> Index: defs.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/defs.h,v
> retrieving revision 1.34
> diff -c -3 -p -r1.34 defs.h
> *** defs.h 2001/01/19 08:01:46 1.34
> --- defs.h 2001/01/23 21:01:16
> *************** extern double atof (const char *); /* X3
> *** 962,968 ****
> #ifndef MALLOC_INCOMPATIBLE
>
> #ifdef NEED_DECLARATION_MALLOC
> ! extern PTR malloc ();
> #endif
>
> #ifdef NEED_DECLARATION_REALLOC
> --- 962,968 ----
> #ifndef MALLOC_INCOMPATIBLE
>
> #ifdef NEED_DECLARATION_MALLOC
> ! extern PTR xmalloc ();
> #endif
>
> #ifdef NEED_DECLARATION_REALLOC
I'm not sure if I mentioned it earlier, but xmalloc() doesn't need to
be declared here since its declaration comes in through libiberty.h.
I think that what should happen in this case is that these three
lines...
#ifdef NEED_DECLARATION_MALLOC
extern PTR malloc ();
#endif
...should be moved to utils.c since this is the only file that
malloc() is used in. (In a perfect world, they could simply go away
because all hosts would have malloc declared in the appropriate header
file (stdlib.h).)
> Index: config/pa/xm-hppah.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/config/pa/xm-hppah.h,v
> retrieving revision 1.2
> diff -c -3 -p -r1.2 xm-hppah.h
> *** xm-hppah.h 2000/05/28 01:12:37 1.2
> --- xm-hppah.h 2001/01/23 21:01:47
> ***************
> *** 40,46 ****
>
> #define MALLOC_INCOMPATIBLE
>
> ! extern void *malloc (size_t);
>
> extern void *realloc (void *, size_t);
>
> --- 40,46 ----
>
> #define MALLOC_INCOMPATIBLE
>
> ! extern void *xmalloc (size_t);
>
> extern void *realloc (void *, size_t);
>
>
Again, xmalloc() doesn't need to be declared here since it comes in
through libiberty.h. malloc() doesn't need to be declared either
since its only use is in utils.c. Thus, the declaration in question
can go away entirely.