This is the mail archive of the
gdb@sourceware.cygnus.com
mailing list for the GDB project.
Re: #define XMALLOC(TYPE) (TYPE*) xmalloc (sizeof (TYPE))
- To: cagney at cygnus dot com
- Subject: Re: #define XMALLOC(TYPE) (TYPE*) xmalloc (sizeof (TYPE))
- From: Stan Shebs <shebs at cygnus dot com>
- Date: Wed, 3 Nov 1999 19:20:33 -0800
- CC: gdb at sourceware dot cygnus dot com
From: Andrew Cagney <ac131313@cygnus.com>
Date: Wed, 03 Nov 1999 20:11:30 +1100
Here is a style question. A convention I adopted when developing psim
(gdb/sim/ppc) was to use the macro:
#define XMALLOC(TYPE) (TYPE*) xmalloc (sizeof (TYPE))
I have mixed feelings about this. The simplification is attractive,
but I'm cringing at the idea of introducing still more macros into
the sources (although I notice that you introduced it into several
files already...). Also, this version only simplifies the singleton
allocations, though admittedly those seem to account for about 2/3
of the xmalloc calls.
If everybody else likes this, I'll go along.
It's a poor persons ``new()''. Would people react violently if this
definition was pushed into defs.h where it could be used more widely?
This is very different to making it a requirement of any coding
standard.
If we *do* use this, I would rather encourage its use, add a
multiplying version (call it XMALLOC_N or some such), deprecate bare
calls to xmalloc, and - ideally - change all the existing calls. It's
much more important to me to be consistent throughout the code.
Otherwise future GDB hackers will scratch their heads and wonder
whether they're supposed to be using xmalloc or XMALLOC.
Stan