diff options
-rw-r--r-- | gdb/ChangeLog | 13 | ||||
-rw-r--r-- | gdb/ch-exp.c | 14 | ||||
-rw-r--r-- | gdb/f-lang.c | 29 | ||||
-rw-r--r-- | gdb/gnu-regex.c | 2 | ||||
-rw-r--r-- | gdb/stabsread.c | 2 |
5 files changed, 26 insertions, 34 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 97c12b9..505166d 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,16 @@ +Mon Feb 12 13:11:32 1996 Fred Fish <fnf@cygnus.com> + + * f-lang.c (allocate_saved_bf_node, allocate_saved_function_node, + allocate_saved_f77_common_node, allocate_common_entry_node, + add_common_block): Use xmalloc rather than malloc, some of which + were unchecked. + * gnu-regex.c: At same point as other gdb specific changes + #undef malloc and then #define it to xmalloc. + * ch-exp.c (growbuf_by_size): Use xmalloc/xrealloc rather than + bare unchecked calls to malloc/realloc. + * stabsread.c (dbx_lookup_type): Use xmalloc rather than bare + unchecked call to malloc. + Wed Feb 7 11:31:26 1996 Stu Grossman (grossman@cygnus.com) * symtab.c (gdb_mangle_name): Change opname var to be const to diff --git a/gdb/ch-exp.c b/gdb/ch-exp.c index 95021e7..4767d94 100644 --- a/gdb/ch-exp.c +++ b/gdb/ch-exp.c @@ -26,15 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ during the process of parsing; the lower levels of the tree always 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. - - Also note that the language accepted by this parser is more liberal + Note that the language accepted by this parser is more liberal than the one accepted by an actual Chill compiler. For example, the language rule that a simple name string can not be one of the reserved simple name strings is not enforced (e.g "case" is not treated as a @@ -1094,11 +1086,11 @@ growbuf_by_size (count) tempbufsize += growby; if (tempbuf == NULL) { - tempbuf = (char *) malloc (tempbufsize); + tempbuf = (char *) xmalloc (tempbufsize); } else { - tempbuf = (char *) realloc (tempbuf, tempbufsize); + tempbuf = (char *) xrealloc (tempbuf, tempbufsize); } } diff --git a/gdb/f-lang.c b/gdb/f-lang.c index 47a8893..65ad64c 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -547,10 +547,7 @@ SAVED_BF_PTR allocate_saved_bf_node() { SAVED_BF_PTR new; - new = (SAVED_BF_PTR) malloc (sizeof (SAVED_BF)); - - if (new == NULL) - fatal("could not allocate enough memory to save one more .bf on save list"); + new = (SAVED_BF_PTR) xmalloc (sizeof (SAVED_BF)); return(new); } @@ -558,11 +555,7 @@ SAVED_FUNCTION *allocate_saved_function_node() { SAVED_FUNCTION *new; - new = (SAVED_FUNCTION *) malloc (sizeof (SAVED_FUNCTION)); - - if (new == NULL) - fatal("could not allocate enough memory to save one more function on save list"); - + new = (SAVED_FUNCTION *) xmalloc (sizeof (SAVED_FUNCTION)); return(new); } @@ -570,11 +563,7 @@ SAVED_F77_COMMON_PTR allocate_saved_f77_common_node() { SAVED_F77_COMMON_PTR new; - new = (SAVED_F77_COMMON_PTR) malloc (sizeof (SAVED_F77_COMMON)); - - if (new == NULL) - fatal("could not allocate enough memory to save one more F77 COMMON blk on save list"); - + new = (SAVED_F77_COMMON_PTR) xmalloc (sizeof (SAVED_F77_COMMON)); return(new); } @@ -582,11 +571,7 @@ COMMON_ENTRY_PTR allocate_common_entry_node() { COMMON_ENTRY_PTR new; - new = (COMMON_ENTRY_PTR) malloc (sizeof (COMMON_ENTRY)); - - if (new == NULL) - fatal("could not allocate enough memory to save one more COMMON entry on save list"); - + new = (COMMON_ENTRY_PTR) xmalloc (sizeof (COMMON_ENTRY)); return(new); } @@ -635,10 +620,10 @@ void add_common_block(name,offset,secnum,func_stab) tmp = allocate_saved_f77_common_node(); - local_copy_func_stab = malloc (strlen(func_stab) + 1); + local_copy_func_stab = xmalloc (strlen(func_stab) + 1); strcpy(local_copy_func_stab,func_stab); - tmp->name = malloc(strlen(name) + 1); + tmp->name = xmalloc(strlen(name) + 1); /* local_copy_func_stab is a stabstring, let us first extract the function name from the stab by NULLing out the ':' character. */ @@ -653,7 +638,7 @@ void add_common_block(name,offset,secnum,func_stab) error("Malformed function STAB found in add_common_block()"); - tmp->owning_function = malloc (strlen(local_copy_func_stab) + 1); + tmp->owning_function = xmalloc (strlen(local_copy_func_stab) + 1); strcpy(tmp->owning_function,local_copy_func_stab); diff --git a/gdb/gnu-regex.c b/gdb/gnu-regex.c index 062fbc6..601e3b5 100644 --- a/gdb/gnu-regex.c +++ b/gdb/gnu-regex.c @@ -34,6 +34,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "defs.h" #include "gdb_string.h" +#undef malloc +#define malloc xmalloc /* * Define the syntax stuff, so we can do the \<...\> things. diff --git a/gdb/stabsread.c b/gdb/stabsread.c index 541e886..4ea4ba3 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -291,7 +291,7 @@ Invalid symbol data: type number (%d,%d) out of range at symtab pos %d.", { type_vector_length = INITIAL_TYPE_VECTOR_LENGTH; type_vector = (struct type **) - malloc (type_vector_length * sizeof (struct type *)); + xmalloc (type_vector_length * sizeof (struct type *)); } while (index >= type_vector_length) { |