diff options
author | Andrew Cagney <cagney@redhat.com> | 2001-03-20 01:37:10 +0000 |
---|---|---|
committer | Andrew Cagney <cagney@redhat.com> | 2001-03-20 01:37:10 +0000 |
commit | 3c37485b16d873d9fd8d5d448dce60a2d890e286 (patch) | |
tree | 01b974afe0c43b13dc0a0efda5ce8f0cf4b1a6a4 | |
parent | 0e52036f1f47078a9863f6a377ff11e10a81e8c4 (diff) | |
download | gdb-3c37485b16d873d9fd8d5d448dce60a2d890e286.zip gdb-3c37485b16d873d9fd8d5d448dce60a2d890e286.tar.gz gdb-3c37485b16d873d9fd8d5d448dce60a2d890e286.tar.bz2 |
malloc() -> xmalloc.
Move malloc() decl to utils.c
-rw-r--r-- | gdb/ChangeLog | 18 | ||||
-rw-r--r-- | gdb/defs.h | 8 | ||||
-rw-r--r-- | gdb/gdbtypes.c | 3 | ||||
-rw-r--r-- | gdb/gnu-nat.c | 7 | ||||
-rw-r--r-- | gdb/hp-psymtab-read.c | 6 | ||||
-rw-r--r-- | gdb/infttrace.c | 6 | ||||
-rw-r--r-- | gdb/procfs.c | 7 | ||||
-rw-r--r-- | gdb/remote-rdp.c | 8 | ||||
-rw-r--r-- | gdb/utils.c | 3 | ||||
-rw-r--r-- | gdb/valprint.c | 4 |
10 files changed, 34 insertions, 36 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 4bdc8f3..7df5486 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,23 @@ 2001-03-19 Andrew Cagney <ac131313@redhat.com> + * defs.h (malloc): Move declaration from here. + * utils.c (malloc): To here. + * config/pa/xm-hppah.h (malloc): Delete declaration. + + * gnu-nat.c (make_proc): Use xmalloc instead of malloc. + * hp-psymtab-read.c (hpread_call_pxdb): Ditto. + (hpread_quick_traverse): Ditto. + * infttrace.c (create_thread_info): Ditto. + (kill_inferior): Ditto. + * gnu-nat.c (make_inf): Ditto, and don't check return value. + * procfs.c (proc_update_threads): Ditto. + * valprint.c (print_decimal_chars): Ditto. + * gdbtypes.c (cfront_mangle_name): Use xasprintf instead of + malloc and sprintf. + * remote-rdp.c (rdp_set_command_line): Ditto. + +2001-03-19 Andrew Cagney <ac131313@redhat.com> + * defs.h (realloc): Move declaration from here. * utils.c (realloc): To here. * config/pa/xm-hppah.h (realloc): Delete declaration. @@ -945,14 +945,6 @@ extern int fclose (FILE *); extern double atof (const char *); /* X3.159-1989 4.10.1.1 */ #endif -#ifndef MALLOC_INCOMPATIBLE - -#ifdef NEED_DECLARATION_MALLOC -extern PTR malloc (); -#endif - -#endif /* MALLOC_INCOMPATIBLE */ - /* Various possibilities for alloca. */ #ifndef alloca #ifdef __GNUC__ diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 73966f0..86499e2 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -1350,8 +1350,7 @@ cfront_mangle_name (struct type *type, int i, int j) } ADD_EXTRA ('\0') printf ("add_mangled_type: %s\n", extras.str); /* FIXME */ - arm_mangled_name = malloc (strlen (mangled_name) + extras.len); - sprintf (arm_mangled_name, "%s%s", mangled_name, extras.str); + xasprintf (&arm_mangled_name, "%s%s", mangled_name, extras.str); xfree (mangled_name); mangled_name = arm_mangled_name; } diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c index 54b543b..3ec3352 100644 --- a/gdb/gnu-nat.c +++ b/gdb/gnu-nat.c @@ -539,7 +539,7 @@ make_proc (struct inf *inf, mach_port_t port, int tid) { error_t err; mach_port_t prev_port = MACH_PORT_NULL; - struct proc *proc = malloc (sizeof (struct proc)); + struct proc *proc = xmalloc (sizeof (struct proc)); proc->port = port; proc->tid = tid; @@ -636,10 +636,7 @@ _proc_free (struct proc *proc) struct inf * make_inf (void) { - struct inf *inf = malloc (sizeof (struct inf)); - - if (!inf) - return 0; + struct inf *inf = xmalloc (sizeof (struct inf)); inf->task = 0; inf->threads = 0; diff --git a/gdb/hp-psymtab-read.c b/gdb/hp-psymtab-read.c index 6b62985..ad001d3 100644 --- a/gdb/hp-psymtab-read.c +++ b/gdb/hp-psymtab-read.c @@ -118,7 +118,7 @@ hpread_call_pxdb (char *file_name) if (file_exists (PXDB_SVR4)) { - p = malloc (strlen (PXDB_SVR4) + strlen (file_name) + 2); + p = xmalloc (strlen (PXDB_SVR4) + strlen (file_name) + 2); strcpy (p, PXDB_SVR4); strcat (p, " "); strcat (p, file_name); @@ -946,7 +946,7 @@ hpread_quick_traverse (struct objfile *objfile, char *gntt_bits, static_syms); /* Set up to only enter each class referenced in this module once. */ - class_entered = malloc (B_BYTES (pxdb_header_p->cd_entries)); + class_entered = xmalloc (B_BYTES (pxdb_header_p->cd_entries)); B_CLRALL (class_entered, pxdb_header_p->cd_entries); /* Scan the procedure descriptors for procedures in the current @@ -1174,7 +1174,7 @@ hpread_quick_traverse (struct objfile *objfile, char *gntt_bits, static_syms); /* Set up to only enter each class referenced in this module once. */ - class_entered = malloc (B_BYTES (pxdb_header_p->cd_entries)); + class_entered = xmalloc (B_BYTES (pxdb_header_p->cd_entries)); B_CLRALL (class_entered, pxdb_header_p->cd_entries); /* Scan the procedure descriptors for procedures in the current diff --git a/gdb/infttrace.c b/gdb/infttrace.c index 4cf1faa..3229f35 100644 --- a/gdb/infttrace.c +++ b/gdb/infttrace.c @@ -602,7 +602,7 @@ create_thread_info (int pid, lwpid_t tid) thread_info *p; int thread_count_of_pid; - new_p = malloc (sizeof (thread_info)); + new_p = xmalloc (sizeof (thread_info)); new_p->pid = pid; new_p->tid = tid; new_p->have_signal = 0; @@ -3830,8 +3830,8 @@ kill_inferior (void) zaps the target vector. */ - paranoia = (thread_info **) malloc (thread_head.count * - sizeof (thread_info *)); + paranoia = (thread_info **) xmalloc (thread_head.count * + sizeof (thread_info *)); para_count = 0; t = thread_head.head; diff --git a/gdb/procfs.c b/gdb/procfs.c index 8586238..94439e3 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -2876,9 +2876,7 @@ proc_update_threads (procinfo *pi) if ((nlwp = proc_get_nthreads (pi)) <= 1) return 1; /* Process is not multi-threaded; nothing to do. */ - if ((prstatus = (gdb_prstatus_t *) - malloc (sizeof (gdb_prstatus_t) * (nlwp + 1))) == 0) - perror_with_name ("procfs: malloc failed in update_threads"); + prstatus = xmalloc (sizeof (gdb_prstatus_t) * (nlwp + 1)); old_chain = make_cleanup (xfree, prstatus); if (ioctl (pi->ctl_fd, PIOCLSTATUS, prstatus) < 0) @@ -2984,8 +2982,7 @@ proc_update_threads (procinfo *pi) if (nthreads < 2) return 0; /* nothing to do for 1 or fewer threads */ - if ((threads = malloc (nthreads * sizeof (tid_t))) == NULL) - proc_error (pi, "update_threads, malloc", __LINE__); + threads = xmalloc (nthreads * sizeof (tid_t)); if (ioctl (pi->ctl_fd, PIOCTLIST, threads) < 0) proc_error (pi, "procfs: update_threads (PIOCTLIST)", __LINE__); diff --git a/gdb/remote-rdp.c b/gdb/remote-rdp.c index e9002de..1c9b3c3 100644 --- a/gdb/remote-rdp.c +++ b/gdb/remote-rdp.c @@ -699,13 +699,7 @@ rdp_set_command_line (char *command, char *args) if (commandline != NULL) xfree (commandline); - commandline = malloc (strlen (command) + strlen (args) + 2); - if (commandline != NULL) - { - strcpy (commandline, command); - strcat (commandline, " "); - strcat (commandline, args); - } + xasprintf (&commandline, %s %s", command, args); } static void diff --git a/gdb/utils.c b/gdb/utils.c index 6d164e4..b1205d6 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -57,6 +57,9 @@ #include <readline/readline.h> #ifndef MALLOC_INCOMPATIBLE +#ifdef NEED_DECLARATION_MALLOC +extern PTR malloc (); +#endif #ifdef NEED_DECLARATION_REALLOC extern PTR realloc (); #endif diff --git a/gdb/valprint.c b/gdb/valprint.c index ccd4542..49c6cb8 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -838,9 +838,7 @@ print_decimal_chars (struct ui_file *stream, unsigned char *valaddr, * as the base 16 number, which is 2 digits per byte. */ decimal_len = len * 2 * 2; - digits = (unsigned char *) malloc (decimal_len); - if (digits == NULL) - error ("Can't allocate memory for conversion to decimal."); + digits = xmalloc (decimal_len); for (i = 0; i < decimal_len; i++) { |