aboutsummaryrefslogtreecommitdiff
path: root/gdb/c-exp.y
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/c-exp.y')
-rw-r--r--gdb/c-exp.y26
1 files changed, 11 insertions, 15 deletions
diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index 3389142..3fe853e 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -24,7 +24,15 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
See expression.h for the details of the format.
What is important here is that it can be built up sequentially
during the process of parsing; the lower levels of the tree always
- come first in the result. */
+ come first in the result.
+
+ Note that malloc's and realloc's in this file are transformed to
+ xmalloc and xrealloc respectively by the same sed command in the
+ makefile that remaps any other malloc/realloc inserted by the parser
+ generator. Doing this with #defines and trying to control the interaction
+ with include files (<malloc.h> and <stdlib.h> for example) just became
+ too messy, particularly when such includes can be inserted at random
+ times by the parser generator. */
%{
@@ -193,18 +201,6 @@ parse_number PARAMS ((char *, int, int, YYSTYPE *));
%type <bval> block
%left COLONCOLON
-%{
-/* Ensure that if the generated parser contains any calls to malloc/realloc,
- that they get mapped to xmalloc/xrealloc. We have to do this here
- rather than earlier in the file because this is the first point after
- the place where the SVR4 yacc includes <malloc.h>, and if we do it
- before that, then the remapped declarations in <malloc.h> will collide
- with the ones in "defs.h". */
-
-#define malloc xmalloc
-#define realloc xrealloc
-%}
-
%%
@@ -913,13 +909,13 @@ typename: TYPENAME
nonempty_typelist
: type
- { $$ = (struct type **) xmalloc (sizeof (struct type *) * 2);
+ { $$ = (struct type **) malloc (sizeof (struct type *) * 2);
$<ivec>$[0] = 1; /* Number of types in vector */
$$[1] = $1;
}
| nonempty_typelist ',' type
{ int len = sizeof (struct type *) * (++($<ivec>1[0]) + 1);
- $$ = (struct type **) xrealloc ((char *) $1, len);
+ $$ = (struct type **) realloc ((char *) $1, len);
$$[$<ivec>$[0]] = $3;
}
;