public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/3] remove overlapping allocation macros
@ 2014-01-06 17:32 Tom Tromey
  2014-01-06 17:32 ` [PATCH 2/3] replace XMALLOC with XNEW Tom Tromey
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: Tom Tromey @ 2014-01-06 17:32 UTC (permalink / raw)
  To: gdb-patches

Right now, gdb defines some allocation macros in defs.h, specifically
XZALLOC, XMALLOC, and XCALLOC.  libiberty also defines similar
allocation macros, and gdb uses both variants.

I think it's somewhat nicer if gdb uses just a single set of wrapper
macros, and so this patch series replaces all the uses of the gdb
macros with the corresponding macros from libiberty.

Let me know what you think.

Tested by rebuilding on x86-64 Fedora 18 and doing a cross build to
mingw.  It's possible therefore that there are some buglets remaining.

Tom

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 3/3] replace XCALLOC with XCNEWVEC or XCNEW
  2014-01-06 17:32 [PATCH 0/3] remove overlapping allocation macros Tom Tromey
  2014-01-06 17:32 ` [PATCH 2/3] replace XMALLOC with XNEW Tom Tromey
@ 2014-01-06 17:32 ` Tom Tromey
  2014-01-06 17:32 ` [PATCH 1/3] replace XZALLOC with XCNEW Tom Tromey
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Tom Tromey @ 2014-01-06 17:32 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This removes XCALLOC and replaces it either with XCNEWVEC, or, if the
number of elements being requested was 1, with XCNEW.

2014-01-06  Tom Tromey  <tromey@redhat.com>

	* defs.h (XCALLOC): Remove.
	* bcache.c (bcache_xmalloc): Use XCNEW, not XCALLOC.
	(print_bcache_statistics): Use XCNEWVEC, not XCALLOC.
	* dwarf2loc.c (allocate_piece_closure): Likewise.
	* elfread.c (elf_symfile_segments): Likewise.
	(elf_symfile_segments): Likewise.
	* gdbtypes.c (copy_type_recursive): Likewise.
	* i386-tdep.c (i386_gdbarch_init): Use XCNEW, not XCALLOC.
	* jit.c (jit_frame_sniffer): Use XCNEWVEC, not XCALLOC.
	* minsyms.c (prim_record_minimal_symbol_full): Use XCNEW, not
	XCALLOC.
	* mt-tdep.c (mt_gdbarch_init): Likewise.
	* opencl-lang.c (allocate_lval_closure): Use XCNEWVEC, not
	XCALLOC.
	* psymtab.c (psymbol_compare): Use XCNEW, not XCALLOC.
	* regcache.c (regcache_xmalloc_1): Use XCNEWVEC, not XCALLOC.
	* registry.c (registry_alloc_data): Likewise.
	* rs6000-tdep.c (rs6000_gdbarch_init): Use XCNEW, not XCALLOC.
	* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
	* serial.c (serial_fdopen_ops): Likewise.
	* solib-aix.c (solib_aix_get_section_offsets): Use XCNEWVEC, not
	XCALLOC.
	* spu-tdep.c (spu_gdbarch_init): Use XCNEW, not XCALLOC.
	* symfile.c (default_symfile_segments): Use XCNEW and XCNEWVEC,
	not XCALLOC.
---
 gdb/ChangeLog         | 28 ++++++++++++++++++++++++++++
 gdb/bcache.c          |  6 +++---
 gdb/defs.h            |  5 -----
 gdb/dwarf2loc.c       |  2 +-
 gdb/elfread.c         |  6 +++---
 gdb/gdbtypes.c        |  2 +-
 gdb/i386-tdep.c       |  2 +-
 gdb/jit.c             |  4 ++--
 gdb/minsyms.c         |  2 +-
 gdb/mt-tdep.c         |  2 +-
 gdb/opencl-lang.c     |  2 +-
 gdb/psymtab.c         |  2 +-
 gdb/regcache.c        |  8 ++++----
 gdb/registry.c        |  2 +-
 gdb/rs6000-tdep.c     |  2 +-
 gdb/s390-linux-tdep.c |  2 +-
 gdb/serial.c          |  2 +-
 gdb/solib-aix.c       |  2 +-
 gdb/spu-tdep.c        |  2 +-
 gdb/symfile.c         |  6 +++---
 20 files changed, 56 insertions(+), 33 deletions(-)

diff --git a/gdb/bcache.c b/gdb/bcache.c
index 3d1280a..99e9184 100644
--- a/gdb/bcache.c
+++ b/gdb/bcache.c
@@ -313,7 +313,7 @@ bcache_xmalloc (unsigned long (*hash_function)(const void *, int length),
 					int length))
 {
   /* Allocate the bcache pre-zeroed.  */
-  struct bcache *b = XCALLOC (1, struct bcache);
+  struct bcache *b = XCNEW (struct bcache);
 
   if (hash_function)
     b->hash_function = hash_function;
@@ -372,8 +372,8 @@ print_bcache_statistics (struct bcache *c, char *type)
      lengths, and measure chain lengths.  */
   {
     unsigned int b;
-    int *chain_length = XCALLOC (c->num_buckets + 1, int);
-    int *entry_size = XCALLOC (c->unique_count + 1, int);
+    int *chain_length = XCNEWVEC (int, c->num_buckets + 1);
+    int *entry_size = XCNEWVEC (int, c->unique_count + 1);
     int stringi = 0;
 
     occupied_buckets = 0;
diff --git a/gdb/defs.h b/gdb/defs.h
index a4770ef..a7ce88a 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -553,11 +553,6 @@ enum val_prettyformat
 
 extern int longest_to_int (LONGEST);
 
-/* Utility macros to allocate typed memory.  Avoids errors like:
-   struct foo *foo = xmalloc (sizeof struct bar); and memset (foo,
-   sizeof (struct foo), 0).  */
-#define XCALLOC(NMEMB, TYPE) ((TYPE*) xcalloc ((NMEMB), sizeof (TYPE)))
-
 #include "common-utils.h"
 
 /* List of known OS ABIs.  If you change this, make sure to update the
diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
index 6185a6b..99a18a9 100644
--- a/gdb/dwarf2loc.c
+++ b/gdb/dwarf2loc.c
@@ -1421,7 +1421,7 @@ allocate_piece_closure (struct dwarf2_per_cu_data *per_cu,
   c->per_cu = per_cu;
   c->n_pieces = n_pieces;
   c->addr_size = addr_size;
-  c->pieces = XCALLOC (n_pieces, struct dwarf_expr_piece);
+  c->pieces = XCNEWVEC (struct dwarf_expr_piece, n_pieces);
 
   memcpy (c->pieces, pieces, n_pieces * sizeof (struct dwarf_expr_piece));
   for (i = 0; i < n_pieces; ++i)
diff --git a/gdb/elfread.c b/gdb/elfread.c
index 4f27aff..d43a1f7 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -107,8 +107,8 @@ elf_symfile_segments (bfd *abfd)
 
   data = XCNEW (struct symfile_segment_data);
   data->num_segments = num_segments;
-  data->segment_bases = XCALLOC (num_segments, CORE_ADDR);
-  data->segment_sizes = XCALLOC (num_segments, CORE_ADDR);
+  data->segment_bases = XCNEWVEC (CORE_ADDR, num_segments);
+  data->segment_sizes = XCNEWVEC (CORE_ADDR, num_segments);
 
   for (i = 0; i < num_segments; i++)
     {
@@ -117,7 +117,7 @@ elf_symfile_segments (bfd *abfd)
     }
 
   num_sections = bfd_count_sections (abfd);
-  data->segment_info = XCALLOC (num_sections, int);
+  data->segment_info = XCNEWVEC (int, num_sections);
 
   for (i = 0, sect = abfd->sections; sect != NULL; i++, sect = sect->next)
     {
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index e02b66c..042c17d 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -3700,7 +3700,7 @@ copy_type_recursive (struct objfile *objfile,
       int i, nfields;
 
       nfields = TYPE_NFIELDS (type);
-      TYPE_FIELDS (new_type) = XCALLOC (nfields, struct field);
+      TYPE_FIELDS (new_type) = XCNEWVEC (struct field, nfields);
       for (i = 0; i < nfields; i++)
 	{
 	  TYPE_FIELD_ARTIFICIAL (new_type, i) = 
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index ce44ffd..588683fd 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -7792,7 +7792,7 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
     return arches->gdbarch;
 
   /* Allocate space for the new architecture.  */
-  tdep = XCALLOC (1, struct gdbarch_tdep);
+  tdep = XCNEW (struct gdbarch_tdep);
   gdbarch = gdbarch_alloc (&info, tdep);
 
   /* General-purpose registers.  */
diff --git a/gdb/jit.c b/gdb/jit.c
index 59823a5..a73ed64 100644
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -1184,8 +1184,8 @@ jit_frame_sniffer (const struct frame_unwind *self,
   *cache = XCNEW (struct jit_unwind_private);
   priv_data = *cache;
   priv_data->registers =
-    XCALLOC (gdbarch_num_regs (get_frame_arch (this_frame)),
-             struct gdb_reg_value *);
+    XCNEWVEC (struct gdb_reg_value *,	      
+	      gdbarch_num_regs (get_frame_arch (this_frame)));
   priv_data->this_frame = this_frame;
 
   callbacks.priv_data = priv_data;
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index ee9575c..c7ae981 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -935,7 +935,7 @@ prim_record_minimal_symbol_full (const char *name, int name_len, int copy_name,
 
   if (msym_bunch_index == BUNCH_SIZE)
     {
-      new = XCALLOC (1, struct msym_bunch);
+      new = XCNEW (struct msym_bunch);
       msym_bunch_index = 0;
       new->next = msym_bunch;
       msym_bunch = new;
diff --git a/gdb/mt-tdep.c b/gdb/mt-tdep.c
index 2072528..e3786e8 100644
--- a/gdb/mt-tdep.c
+++ b/gdb/mt-tdep.c
@@ -1149,7 +1149,7 @@ mt_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   /* None found, create a new architecture from the information
      provided.  */
-  tdep = XCALLOC (1, struct gdbarch_tdep);
+  tdep = XCNEW (struct gdbarch_tdep);
   gdbarch = gdbarch_alloc (&info, tdep);
 
   set_gdbarch_float_format (gdbarch, floatformats_ieee_single);
diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c
index 4327fe6..be6e08d 100644
--- a/gdb/opencl-lang.c
+++ b/gdb/opencl-lang.c
@@ -161,7 +161,7 @@ allocate_lval_closure (int *indices, int n, struct value *val)
 
   c->refc = 1;
   c->n = n;
-  c->indices = XCALLOC (n, int);
+  c->indices = XCNEWVEC (int, n);
   memcpy (c->indices, indices, n * sizeof (int));
   value_incref (val); /* Increment the reference counter of the value.  */
   c->val = val;
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 34e833c..56fe409 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -1530,7 +1530,7 @@ psymbol_compare (const void *addr1, const void *addr2, int length)
 struct psymbol_bcache *
 psymbol_bcache_init (void)
 {
-  struct psymbol_bcache *bcache = XCALLOC (1, struct psymbol_bcache);
+  struct psymbol_bcache *bcache = XCNEW (struct psymbol_bcache);
   bcache->bcache = bcache_xmalloc (psymbol_hash, psymbol_compare);
   return bcache;
 }
diff --git a/gdb/regcache.c b/gdb/regcache.c
index ea52d45..2e9314c 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -224,16 +224,16 @@ regcache_xmalloc_1 (struct gdbarch *gdbarch, struct address_space *aspace,
   if (readonly_p)
     {
       regcache->registers
-	= XCALLOC (descr->sizeof_cooked_registers, gdb_byte);
+	= XCNEWVEC (gdb_byte, descr->sizeof_cooked_registers);
       regcache->register_status
-	= XCALLOC (descr->sizeof_cooked_register_status, signed char);
+	= XCNEWVEC (signed char, descr->sizeof_cooked_register_status);
     }
   else
     {
       regcache->registers
-	= XCALLOC (descr->sizeof_raw_registers, gdb_byte);
+	= XCNEWVEC (gdb_byte, descr->sizeof_raw_registers);
       regcache->register_status
-	= XCALLOC (descr->sizeof_raw_register_status, signed char);
+	= XCNEWVEC (signed char, descr->sizeof_raw_register_status);
     }
   regcache->aspace = aspace;
   regcache->ptid = minus_one_ptid;
diff --git a/gdb/registry.c b/gdb/registry.c
index ed614b9..2fd6033 100644
--- a/gdb/registry.c
+++ b/gdb/registry.c
@@ -51,7 +51,7 @@ registry_alloc_data (struct registry_data_registry *registry,
 {
   gdb_assert (fields->data == NULL);
   fields->num_data = registry->num_registrations;
-  fields->data = XCALLOC (fields->num_data, void *);
+  fields->data = XCNEWVEC (void *, fields->num_data);
 }
 
 void
diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c
index 0008f84..d7416e5 100644
--- a/gdb/rs6000-tdep.c
+++ b/gdb/rs6000-tdep.c
@@ -3954,7 +3954,7 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
        - "set arch"		trust blindly
        - GDB startup		useless but harmless */
 
-  tdep = XCALLOC (1, struct gdbarch_tdep);
+  tdep = XCNEW (struct gdbarch_tdep);
   tdep->wordsize = wordsize;
   tdep->soft_float = soft_float;
   tdep->vector_abi = vector_abi;
diff --git a/gdb/s390-linux-tdep.c b/gdb/s390-linux-tdep.c
index 69befcf..b75c86a 100644
--- a/gdb/s390-linux-tdep.c
+++ b/gdb/s390-linux-tdep.c
@@ -3196,7 +3196,7 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
     }
 
   /* Otherwise create a new gdbarch for the specified machine type.  */
-  tdep = XCALLOC (1, struct gdbarch_tdep);
+  tdep = XCNEW (struct gdbarch_tdep);
   tdep->abi = tdep_abi;
   gdbarch = gdbarch_alloc (&info, tdep);
 
diff --git a/gdb/serial.c b/gdb/serial.c
index c87875f..2b1eced 100644
--- a/gdb/serial.c
+++ b/gdb/serial.c
@@ -263,7 +263,7 @@ serial_fdopen_ops (const int fd, const struct serial_ops *ops)
   if (!ops)
     return NULL;
 
-  scb = XCALLOC (1, struct serial);
+  scb = XCNEW (struct serial);
 
   scb->ops = ops;
 
diff --git a/gdb/solib-aix.c b/gdb/solib-aix.c
index 8f335f6..78d2753 100644
--- a/gdb/solib-aix.c
+++ b/gdb/solib-aix.c
@@ -470,7 +470,7 @@ solib_aix_get_section_offsets (struct objfile *objfile,
   bfd *abfd = objfile->obfd;
   int i;
 
-  offsets = XCALLOC (objfile->num_sections, struct section_offsets);
+  offsets = XCNEWVEC (struct section_offsets, objfile->num_sections);
 
   /* .text */
 
diff --git a/gdb/spu-tdep.c b/gdb/spu-tdep.c
index 4d745d9..f096a2e 100644
--- a/gdb/spu-tdep.c
+++ b/gdb/spu-tdep.c
@@ -2658,7 +2658,7 @@ spu_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
     }
 
   /* None found, so create a new architecture.  */
-  tdep = XCALLOC (1, struct gdbarch_tdep);
+  tdep = XCNEW (struct gdbarch_tdep);
   tdep->id = id;
   gdbarch = gdbarch_alloc (&info, tdep);
 
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 75e71cb..dcdfd51 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -802,11 +802,11 @@ default_symfile_segments (bfd *abfd)
 
   data = XCNEW (struct symfile_segment_data);
   data->num_segments = 1;
-  data->segment_bases = XCALLOC (1, CORE_ADDR);
-  data->segment_sizes = XCALLOC (1, CORE_ADDR);
+  data->segment_bases = XCNEW (CORE_ADDR);
+  data->segment_sizes = XCNEW (CORE_ADDR);
 
   num_sections = bfd_count_sections (abfd);
-  data->segment_info = XCALLOC (num_sections, int);
+  data->segment_info = XCNEWVEC (int, num_sections);
 
   for (i = 0, sect = abfd->sections; sect != NULL; i++, sect = sect->next)
     {
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 2/3] replace XMALLOC with XNEW
  2014-01-06 17:32 [PATCH 0/3] remove overlapping allocation macros Tom Tromey
@ 2014-01-06 17:32 ` Tom Tromey
  2014-01-06 17:32 ` [PATCH 3/3] replace XCALLOC with XCNEWVEC or XCNEW Tom Tromey
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Tom Tromey @ 2014-01-06 17:32 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This replaces XMALLOC with XNEW, and removes XMALLOC.  The only
non-mechanical bit here was remembering to edit gdbarch.sh.

2014-01-06  Tom Tromey  <tromey@redhat.com>

	* defs.h (XMALLOC): Remove.
	* avr-tdep.c (avr_gdbarch_init): Use XNEW, not XMALLOC.
	* bfin-tdep.c (bfin_gdbarch_init): Likewise.
	* cli-out.c (struct ui_out *): Likewise.
	* cli/cli-dump.c (add_dump_command): Likewise.
	(add_dump_command): Likewise.
	* complaints.c (get_complaints): Likewise.
	(find_complaint): Likewise.
	* dwarf2-frame.c (execute_cfa_program): Likewise.
	* dwarf2read.c (abbrev_table_read_table): Likewise.
	* gdbarch.sh: Likewise.
	* gdbarch.c: Rebuild.
	* inf-ttrace.c (inf_ttrace_add_page): Likewise.
	* interps.c (interp_new): Likewise.
	* lm32-tdep.c (lm32_gdbarch_init): Likewise.
	* m32r-tdep.c (m32r_gdbarch_init): Likewise.
	* mi/mi-console.c (mi_console_file_new): Likewise.
	* mi/mi-interp.c (mi_interpreter_init): Likewise.
	* mi/mi-out.c (mi_out_new): Likewise.
	* mi/mi-parse.c (mi_parse): Likewise.
	* microblaze-tdep.c (microblaze_gdbarch_init): Likewise.
	* moxie-tdep.c (moxie_gdbarch_init): Likewise.
	* observer.c (xalloc_observer_list_node): Likewise.
	* regcache.c (regcache_xmalloc_1): Likewise.
	* reggroups.c (reggroup_new): Likewise.
	(_initialize_reggroup): Likewise.
	* registry.c (register_data_with_cleanup): Likewise.
	* remote.c (remote_notif_stop_alloc_reply): Likewise.
	* ser-base.c (serial_ttystate): Likewise.
	* ser-mingw.c (make_pipe_state): Likewise.
	* ser-pipe.c (pipe_open): Likewise.
	* serial.c (serial_open): Likewise.
	* sh64-tdep.c (sh64_gdbarch_init): Likewise.
	* tui/tui-data.c (tui_alloc_generic_win_info): Likewise.
	(tui_alloc_win_info): Likewise.
	(tui_add_content_elements): Likewise.
	* tui/tui-file.c (tui_file_new): Likewise.
	* tui/tui-out.c (tui_out_new): Likewise.
	* ui-file.c (mem_file_new): Likewise.
	* ui-out.c (push_level): Likewise.
	(make_cleanup_ui_out_end): Likewise.
	(append_header_to_list): Likewise.
	(ui_out_new): Likewise.
	* user-regs.c (user_reg_add_builtin): Likewise.
---
 gdb/ChangeLog         | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 gdb/avr-tdep.c        |  2 +-
 gdb/bfin-tdep.c       |  2 +-
 gdb/cli-out.c         |  2 +-
 gdb/cli/cli-dump.c    |  4 ++--
 gdb/complaints.c      |  4 ++--
 gdb/defs.h            |  1 -
 gdb/dwarf2-frame.c    |  2 +-
 gdb/dwarf2read.c      |  2 +-
 gdb/gdbarch.c         | 10 +++++-----
 gdb/gdbarch.sh        | 10 +++++-----
 gdb/inf-ttrace.c      |  2 +-
 gdb/interps.c         |  2 +-
 gdb/lm32-tdep.c       |  2 +-
 gdb/m32r-tdep.c       |  2 +-
 gdb/mi/mi-console.c   |  2 +-
 gdb/mi/mi-interp.c    |  2 +-
 gdb/mi/mi-out.c       |  2 +-
 gdb/mi/mi-parse.c     |  2 +-
 gdb/microblaze-tdep.c |  2 +-
 gdb/moxie-tdep.c      |  2 +-
 gdb/observer.c        |  4 ++--
 gdb/regcache.c        |  2 +-
 gdb/reggroups.c       | 16 ++++++++--------
 gdb/registry.c        |  4 ++--
 gdb/remote.c          |  2 +-
 gdb/ser-base.c        |  4 ++--
 gdb/ser-mingw.c       |  2 +-
 gdb/ser-pipe.c        |  2 +-
 gdb/serial.c          |  2 +-
 gdb/sh64-tdep.c       |  2 +-
 gdb/tui/tui-data.c    |  6 +++---
 gdb/tui/tui-file.c    |  2 +-
 gdb/tui/tui-out.c     |  2 +-
 gdb/ui-file.c         |  2 +-
 gdb/ui-out.c          | 10 +++++-----
 gdb/user-regs.c       |  2 +-
 37 files changed, 108 insertions(+), 62 deletions(-)

diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c
index cb330ea..e863678 100644
--- a/gdb/avr-tdep.c
+++ b/gdb/avr-tdep.c
@@ -1377,7 +1377,7 @@ avr_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
     }
 
   /* None found, create a new architecture from the information provided.  */
-  tdep = XMALLOC (struct gdbarch_tdep);
+  tdep = XNEW (struct gdbarch_tdep);
   gdbarch = gdbarch_alloc (&info, tdep);
   
   tdep->call_length = call_length;
diff --git a/gdb/bfin-tdep.c b/gdb/bfin-tdep.c
index d64da0d..3fa8173 100644
--- a/gdb/bfin-tdep.c
+++ b/gdb/bfin-tdep.c
@@ -818,7 +818,7 @@ bfin_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
       return arches->gdbarch;
     }
 
-  tdep = XMALLOC (struct gdbarch_tdep);
+  tdep = XNEW (struct gdbarch_tdep);
   gdbarch = gdbarch_alloc (&info, tdep);
 
   tdep->bfin_abi = abi;
diff --git a/gdb/cli-out.c b/gdb/cli-out.c
index 491d77b..b936f30 100644
--- a/gdb/cli-out.c
+++ b/gdb/cli-out.c
@@ -393,7 +393,7 @@ struct ui_out *
 cli_out_new (struct ui_file *stream)
 {
   int flags = ui_source_list;
-  cli_out_data *data = XMALLOC (cli_out_data);
+  cli_out_data *data = XNEW (cli_out_data);
 
   cli_out_data_ctor (data, stream);
   return ui_out_new (&cli_ui_out_impl, data, flags);
diff --git a/gdb/cli/cli-dump.c b/gdb/cli/cli-dump.c
index c3c2200..005e207 100644
--- a/gdb/cli/cli-dump.c
+++ b/gdb/cli/cli-dump.c
@@ -396,7 +396,7 @@ add_dump_command (char *name, void (*func) (char *args, char *mode),
 
   c = add_cmd (name, all_commands, NULL, descr, &dump_cmdlist);
   c->completer =  filename_completer;
-  d = XMALLOC (struct dump_context);
+  d = XNEW (struct dump_context);
   d->func = func;
   d->mode = FOPEN_WB;
   set_cmd_context (c, d);
@@ -404,7 +404,7 @@ add_dump_command (char *name, void (*func) (char *args, char *mode),
 
   c = add_cmd (name, all_commands, NULL, descr, &append_cmdlist);
   c->completer =  filename_completer;
-  d = XMALLOC (struct dump_context);
+  d = XNEW (struct dump_context);
   d->func = func;
   d->mode = FOPEN_AB;
   set_cmd_context (c, d);
diff --git a/gdb/complaints.c b/gdb/complaints.c
index 64a1bc1..92a3ef6 100644
--- a/gdb/complaints.c
+++ b/gdb/complaints.c
@@ -112,7 +112,7 @@ get_complaints (struct complaints **c)
 {
   if ((*c) != NULL)
     return (*c);
-  (*c) = XMALLOC (struct complaints);
+  (*c) = XNEW (struct complaints);
   (*c)->root = &complaint_sentinel;
   (*c)->series = ISOLATED_MESSAGE;
   (*c)->explanation = NULL;
@@ -140,7 +140,7 @@ find_complaint (struct complaints *complaints, const char *file,
     }
 
   /* Oops not seen before, fill in a new complaint.  */
-  complaint = XMALLOC (struct complain);
+  complaint = XNEW (struct complain);
   complaint->fmt = fmt;
   complaint->file = file;
   complaint->line = line;
diff --git a/gdb/defs.h b/gdb/defs.h
index 4c70cf6..a4770ef 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -556,7 +556,6 @@ extern int longest_to_int (LONGEST);
 /* Utility macros to allocate typed memory.  Avoids errors like:
    struct foo *foo = xmalloc (sizeof struct bar); and memset (foo,
    sizeof (struct foo), 0).  */
-#define XMALLOC(TYPE) ((TYPE*) xmalloc (sizeof (TYPE)))
 #define XCALLOC(NMEMB, TYPE) ((TYPE*) xcalloc ((NMEMB), sizeof (TYPE)))
 
 #include "common-utils.h"
diff --git a/gdb/dwarf2-frame.c b/gdb/dwarf2-frame.c
index 3dcaf27..d6d1bf7 100644
--- a/gdb/dwarf2-frame.c
+++ b/gdb/dwarf2-frame.c
@@ -518,7 +518,7 @@ execute_cfa_program (struct dwarf2_fde *fde, const gdb_byte *insn_ptr,
 	      {
 		struct dwarf2_frame_state_reg_info *new_rs;
 
-		new_rs = XMALLOC (struct dwarf2_frame_state_reg_info);
+		new_rs = XNEW (struct dwarf2_frame_state_reg_info);
 		*new_rs = fs->regs;
 		fs->regs.reg = dwarf2_frame_state_copy_regs (&fs->regs);
 		fs->regs.prev = new_rs;
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 23bcfe0..cbe04be 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -14724,7 +14724,7 @@ abbrev_table_read_table (struct dwarf2_section_info *section,
   struct attr_abbrev *cur_attrs;
   unsigned int allocated_attrs;
 
-  abbrev_table = XMALLOC (struct abbrev_table);
+  abbrev_table = XNEW (struct abbrev_table);
   abbrev_table->offset = offset;
   obstack_init (&abbrev_table->abbrev_obstack);
   abbrev_table->abbrevs = obstack_alloc (&abbrev_table->abbrev_obstack,
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index 0761008..b5a468f 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -505,7 +505,7 @@ gdbarch_alloc (const struct gdbarch_info *info,
 
   /* Create an obstack for allocating all the per-architecture memory,
      then use that to allocate the architecture vector.  */
-  struct obstack *obstack = XMALLOC (struct obstack);
+  struct obstack *obstack = XNEW (struct obstack);
   obstack_init (obstack);
   gdbarch = obstack_alloc (obstack, sizeof (*gdbarch));
   memset (gdbarch, 0, sizeof (*gdbarch));
@@ -4490,9 +4490,9 @@ gdbarch_data_register (gdbarch_data_pre_init_ftype *pre_init,
   for (curr = &gdbarch_data_registry.registrations;
        (*curr) != NULL;
        curr = &(*curr)->next);
-  (*curr) = XMALLOC (struct gdbarch_data_registration);
+  (*curr) = XNEW (struct gdbarch_data_registration);
   (*curr)->next = NULL;
-  (*curr)->data = XMALLOC (struct gdbarch_data);
+  (*curr)->data = XNEW (struct gdbarch_data);
   (*curr)->data->index = gdbarch_data_registry.nr++;
   (*curr)->data->pre_init = pre_init;
   (*curr)->data->post_init = post_init;
@@ -4661,7 +4661,7 @@ gdbarch_register (enum bfd_architecture bfd_architecture,
 			bfd_arch_info->printable_name,
 			host_address_to_string (init));
   /* Append it */
-  (*curr) = XMALLOC (struct gdbarch_registration);
+  (*curr) = XNEW (struct gdbarch_registration);
   (*curr)->bfd_architecture = bfd_architecture;
   (*curr)->init = init;
   (*curr)->dump_tdep = dump_tdep;
@@ -4805,7 +4805,7 @@ gdbarch_find_by_info (struct gdbarch_info info)
   /* Insert the new architecture into the front of the architecture
      list (keep the list sorted Most Recently Used).  */
   {
-    struct gdbarch_list *this = XMALLOC (struct gdbarch_list);
+    struct gdbarch_list *this = XNEW (struct gdbarch_list);
     this->next = rego->arches;
     this->gdbarch = new_gdbarch;
     rego->arches = this;
diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh
index 9e1e03e..ec607c7 100755
--- a/gdb/gdbarch.sh
+++ b/gdb/gdbarch.sh
@@ -1645,7 +1645,7 @@ gdbarch_alloc (const struct gdbarch_info *info,
 
   /* Create an obstack for allocating all the per-architecture memory,
      then use that to allocate the architecture vector.  */
-  struct obstack *obstack = XMALLOC (struct obstack);
+  struct obstack *obstack = XNEW (struct obstack);
   obstack_init (obstack);
   gdbarch = obstack_alloc (obstack, sizeof (*gdbarch));
   memset (gdbarch, 0, sizeof (*gdbarch));
@@ -2005,9 +2005,9 @@ gdbarch_data_register (gdbarch_data_pre_init_ftype *pre_init,
   for (curr = &gdbarch_data_registry.registrations;
        (*curr) != NULL;
        curr = &(*curr)->next);
-  (*curr) = XMALLOC (struct gdbarch_data_registration);
+  (*curr) = XNEW (struct gdbarch_data_registration);
   (*curr)->next = NULL;
-  (*curr)->data = XMALLOC (struct gdbarch_data);
+  (*curr)->data = XNEW (struct gdbarch_data);
   (*curr)->data->index = gdbarch_data_registry.nr++;
   (*curr)->data->pre_init = pre_init;
   (*curr)->data->post_init = post_init;
@@ -2176,7 +2176,7 @@ gdbarch_register (enum bfd_architecture bfd_architecture,
 			bfd_arch_info->printable_name,
 			host_address_to_string (init));
   /* Append it */
-  (*curr) = XMALLOC (struct gdbarch_registration);
+  (*curr) = XNEW (struct gdbarch_registration);
   (*curr)->bfd_architecture = bfd_architecture;
   (*curr)->init = init;
   (*curr)->dump_tdep = dump_tdep;
@@ -2320,7 +2320,7 @@ gdbarch_find_by_info (struct gdbarch_info info)
   /* Insert the new architecture into the front of the architecture
      list (keep the list sorted Most Recently Used).  */
   {
-    struct gdbarch_list *this = XMALLOC (struct gdbarch_list);
+    struct gdbarch_list *this = XNEW (struct gdbarch_list);
     this->next = rego->arches;
     this->gdbarch = new_gdbarch;
     rego->arches = this;
diff --git a/gdb/inf-ttrace.c b/gdb/inf-ttrace.c
index a1c761b..fbc7ed3 100644
--- a/gdb/inf-ttrace.c
+++ b/gdb/inf-ttrace.c
@@ -195,7 +195,7 @@ inf_ttrace_add_page (pid_t pid, CORE_ADDR addr)
 		  addr, 0, (uintptr_t)&prot) == -1)
 	perror_with_name (("ttrace"));
       
-      page = XMALLOC (struct inf_ttrace_page);
+      page = XNEW (struct inf_ttrace_page);
       page->addr = addr;
       page->prot = prot;
       page->refcount = 0;
diff --git a/gdb/interps.c b/gdb/interps.c
index 6d0a76f..e446747 100644
--- a/gdb/interps.c
+++ b/gdb/interps.c
@@ -93,7 +93,7 @@ interp_new (const char *name, const struct interp_procs *procs)
 {
   struct interp *new_interp;
 
-  new_interp = XMALLOC (struct interp);
+  new_interp = XNEW (struct interp);
 
   new_interp->name = xstrdup (name);
   new_interp->data = NULL;
diff --git a/gdb/lm32-tdep.c b/gdb/lm32-tdep.c
index 3ac7f89..bdd5477 100644
--- a/gdb/lm32-tdep.c
+++ b/gdb/lm32-tdep.c
@@ -527,7 +527,7 @@ lm32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
     return arches->gdbarch;
 
   /* None found, create a new architecture from the information provided.  */
-  tdep = XMALLOC (struct gdbarch_tdep);
+  tdep = XNEW (struct gdbarch_tdep);
   gdbarch = gdbarch_alloc (&info, tdep);
 
   /* Type sizes.  */
diff --git a/gdb/m32r-tdep.c b/gdb/m32r-tdep.c
index efea816..0ba1276 100644
--- a/gdb/m32r-tdep.c
+++ b/gdb/m32r-tdep.c
@@ -917,7 +917,7 @@ m32r_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
     return arches->gdbarch;
 
   /* Allocate space for the new architecture.  */
-  tdep = XMALLOC (struct gdbarch_tdep);
+  tdep = XNEW (struct gdbarch_tdep);
   gdbarch = gdbarch_alloc (&info, tdep);
 
   set_gdbarch_read_pc (gdbarch, m32r_read_pc);
diff --git a/gdb/mi/mi-console.c b/gdb/mi/mi-console.c
index d2b8491..dbad199 100644
--- a/gdb/mi/mi-console.c
+++ b/gdb/mi/mi-console.c
@@ -52,7 +52,7 @@ struct ui_file *
 mi_console_file_new (struct ui_file *raw, const char *prefix, char quote)
 {
   struct ui_file *ui_file = ui_file_new ();
-  struct mi_console_file *mi_console = XMALLOC (struct mi_console_file);
+  struct mi_console_file *mi_console = XNEW (struct mi_console_file);
 
   mi_console->magic = &mi_console_file_magic;
   mi_console->raw = raw;
diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c
index c13c0f1..25bf0a1 100644
--- a/gdb/mi/mi-interp.c
+++ b/gdb/mi/mi-interp.c
@@ -83,7 +83,7 @@ static int report_initial_inferior (struct inferior *inf, void *closure);
 static void *
 mi_interpreter_init (struct interp *interp, int top_level)
 {
-  struct mi_interp *mi = XMALLOC (struct mi_interp);
+  struct mi_interp *mi = XNEW (struct mi_interp);
   const char *name;
   int mi_version;
 
diff --git a/gdb/mi/mi-out.c b/gdb/mi/mi-out.c
index 4723d06..a8a3d8d 100644
--- a/gdb/mi/mi-out.c
+++ b/gdb/mi/mi-out.c
@@ -411,7 +411,7 @@ mi_out_new (int mi_version)
 {
   int flags = 0;
 
-  mi_out_data *data = XMALLOC (mi_out_data);
+  mi_out_data *data = XNEW (mi_out_data);
   data->suppress_field_separator = 0;
   data->suppress_output = 0;
   data->mi_version = mi_version;
diff --git a/gdb/mi/mi-parse.c b/gdb/mi/mi-parse.c
index 73151c2..161a16a 100644
--- a/gdb/mi/mi-parse.c
+++ b/gdb/mi/mi-parse.c
@@ -237,7 +237,7 @@ struct mi_parse *
 mi_parse (const char *cmd, char **token)
 {
   const char *chp;
-  struct mi_parse *parse = XMALLOC (struct mi_parse);
+  struct mi_parse *parse = XNEW (struct mi_parse);
   struct cleanup *cleanup;
 
   memset (parse, 0, sizeof (*parse));
diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c
index 078cc32..e2844b2 100644
--- a/gdb/microblaze-tdep.c
+++ b/gdb/microblaze-tdep.c
@@ -677,7 +677,7 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
     return arches->gdbarch;
 
   /* Allocate space for the new architecture.  */
-  tdep = XMALLOC (struct gdbarch_tdep);
+  tdep = XNEW (struct gdbarch_tdep);
   gdbarch = gdbarch_alloc (&info, tdep);
 
   set_gdbarch_long_double_bit (gdbarch, 128);
diff --git a/gdb/moxie-tdep.c b/gdb/moxie-tdep.c
index e1992f9..793e7a4 100644
--- a/gdb/moxie-tdep.c
+++ b/gdb/moxie-tdep.c
@@ -1112,7 +1112,7 @@ moxie_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
     return arches->gdbarch;
 
   /* Allocate space for the new architecture.  */
-  tdep = XMALLOC (struct gdbarch_tdep);
+  tdep = XNEW (struct gdbarch_tdep);
   gdbarch = gdbarch_alloc (&info, tdep);
 
   set_gdbarch_read_pc (gdbarch, moxie_read_pc);
diff --git a/gdb/observer.c b/gdb/observer.c
index 6217c6b..bd7b7ec 100644
--- a/gdb/observer.c
+++ b/gdb/observer.c
@@ -89,9 +89,9 @@ struct observer_list
 static struct observer_list *
 xalloc_observer_list_node (void)
 {
-  struct observer_list *node = XMALLOC (struct observer_list);
+  struct observer_list *node = XNEW (struct observer_list);
 
-  node->observer = XMALLOC (struct observer);
+  node->observer = XNEW (struct observer);
   return node;
 }
 
diff --git a/gdb/regcache.c b/gdb/regcache.c
index 876039d..ea52d45 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -218,7 +218,7 @@ regcache_xmalloc_1 (struct gdbarch *gdbarch, struct address_space *aspace,
 
   gdb_assert (gdbarch != NULL);
   descr = regcache_descr (gdbarch);
-  regcache = XMALLOC (struct regcache);
+  regcache = XNEW (struct regcache);
   regcache->descr = descr;
   regcache->readonly_p = readonly_p;
   if (readonly_p)
diff --git a/gdb/reggroups.c b/gdb/reggroups.c
index 94f2a48..41ec41a 100644
--- a/gdb/reggroups.c
+++ b/gdb/reggroups.c
@@ -39,7 +39,7 @@ struct reggroup
 struct reggroup *
 reggroup_new (const char *name, enum reggroup_type type)
 {
-  struct reggroup *group = XMALLOC (struct reggroup);
+  struct reggroup *group = XNEW (struct reggroup);
 
   group->name = name;
   group->type = type;
@@ -277,13 +277,13 @@ _initialize_reggroup (void)
   reggroups_data = gdbarch_data_register_post_init (reggroups_init);
 
   /* The pre-defined list of groups.  */
-  add_group (&default_groups, general_reggroup, XMALLOC (struct reggroup_el));
-  add_group (&default_groups, float_reggroup, XMALLOC (struct reggroup_el));
-  add_group (&default_groups, system_reggroup, XMALLOC (struct reggroup_el));
-  add_group (&default_groups, vector_reggroup, XMALLOC (struct reggroup_el));
-  add_group (&default_groups, all_reggroup, XMALLOC (struct reggroup_el));
-  add_group (&default_groups, save_reggroup, XMALLOC (struct reggroup_el));
-  add_group (&default_groups, restore_reggroup, XMALLOC (struct reggroup_el));
+  add_group (&default_groups, general_reggroup, XNEW (struct reggroup_el));
+  add_group (&default_groups, float_reggroup, XNEW (struct reggroup_el));
+  add_group (&default_groups, system_reggroup, XNEW (struct reggroup_el));
+  add_group (&default_groups, vector_reggroup, XNEW (struct reggroup_el));
+  add_group (&default_groups, all_reggroup, XNEW (struct reggroup_el));
+  add_group (&default_groups, save_reggroup, XNEW (struct reggroup_el));
+  add_group (&default_groups, restore_reggroup, XNEW (struct reggroup_el));
 
   add_cmd ("reggroups", class_maintenance,
 	   maintenance_print_reggroups, _("\
diff --git a/gdb/registry.c b/gdb/registry.c
index 1a3c295..ed614b9 100644
--- a/gdb/registry.c
+++ b/gdb/registry.c
@@ -35,9 +35,9 @@ register_data_with_cleanup (struct registry_data_registry *registry,
        curr = &(*curr)->next)
     ;
 
-  *curr = XMALLOC (struct registry_data_registration);
+  *curr = XNEW (struct registry_data_registration);
   (*curr)->next = NULL;
-  (*curr)->data = XMALLOC (struct registry_data);
+  (*curr)->data = XNEW (struct registry_data);
   (*curr)->data->index = registry->num_registrations++;
   (*curr)->data->save = save;
   (*curr)->data->free = free;
diff --git a/gdb/remote.c b/gdb/remote.c
index 3f51a93..4696f9b 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -5355,7 +5355,7 @@ static struct notif_event *
 remote_notif_stop_alloc_reply (void)
 {
   struct notif_event *r
-    = (struct notif_event *) XMALLOC (struct stop_reply);
+    = (struct notif_event *) XNEW (struct stop_reply);
 
   r->dtr = stop_reply_dtr;
 
diff --git a/gdb/ser-base.c b/gdb/ser-base.c
index ae92dfb..b8f7fd2 100644
--- a/gdb/ser-base.c
+++ b/gdb/ser-base.c
@@ -498,14 +498,14 @@ serial_ttystate
 ser_base_get_tty_state (struct serial *scb)
 {
   /* Allocate a dummy.  */
-  return (serial_ttystate) XMALLOC (int);
+  return (serial_ttystate) XNEW (int);
 }
 
 serial_ttystate
 ser_base_copy_tty_state (struct serial *scb, serial_ttystate ttystate)
 {
   /* Allocate another dummy.  */
-  return (serial_ttystate) XMALLOC (int);
+  return (serial_ttystate) XNEW (int);
 }
 
 int
diff --git a/gdb/ser-mingw.c b/gdb/ser-mingw.c
index 7247f50..db04999 100644
--- a/gdb/ser-mingw.c
+++ b/gdb/ser-mingw.c
@@ -788,7 +788,7 @@ struct pipe_state
 static struct pipe_state *
 make_pipe_state (void)
 {
-  struct pipe_state *ps = XMALLOC (struct pipe_state);
+  struct pipe_state *ps = XNEW (struct pipe_state);
 
   memset (ps, 0, sizeof (*ps));
   ps->wait.read_event = INVALID_HANDLE_VALUE;
diff --git a/gdb/ser-pipe.c b/gdb/ser-pipe.c
index 9c5b99b..9568a26 100644
--- a/gdb/ser-pipe.c
+++ b/gdb/ser-pipe.c
@@ -134,7 +134,7 @@ pipe_open (struct serial *scb, const char *name)
   if (err_pdes[1] != -1)
     close (err_pdes[1]);
   /* :end chunk */
-  state = XMALLOC (struct pipe_state);
+  state = XNEW (struct pipe_state);
   state->pid = pid;
   scb->fd = pdes[0];
   scb->error_fd = err_pdes[0];
diff --git a/gdb/serial.c b/gdb/serial.c
index 99e33ab..c87875f 100644
--- a/gdb/serial.c
+++ b/gdb/serial.c
@@ -211,7 +211,7 @@ serial_open (const char *name)
   if (!ops)
     return NULL;
 
-  scb = XMALLOC (struct serial);
+  scb = XNEW (struct serial);
 
   scb->ops = ops;
 
diff --git a/gdb/sh64-tdep.c b/gdb/sh64-tdep.c
index 547f139..262de84 100644
--- a/gdb/sh64-tdep.c
+++ b/gdb/sh64-tdep.c
@@ -2370,7 +2370,7 @@ sh64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   /* None found, create a new architecture from the information
      provided.  */
-  tdep = XMALLOC (struct gdbarch_tdep);
+  tdep = XNEW (struct gdbarch_tdep);
   gdbarch = gdbarch_alloc (&info, tdep);
 
   /* Determine the ABI */
diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index 1ceb80f..4deb006 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -447,7 +447,7 @@ tui_alloc_generic_win_info (void)
 {
   struct tui_gen_win_info *win;
 
-  if ((win = XMALLOC (struct tui_gen_win_info)) != NULL)
+  if ((win = XNEW (struct tui_gen_win_info)) != NULL)
     tui_init_generic_part (win);
 
   return win;
@@ -570,7 +570,7 @@ tui_alloc_win_info (enum tui_win_type type)
 {
   struct tui_win_info *win_info;
 
-  win_info = XMALLOC (struct tui_win_info);
+  win_info = XNEW (struct tui_win_info);
   if (win_info != NULL)
     {
       win_info->generic.type = type;
@@ -647,7 +647,7 @@ tui_add_content_elements (struct tui_gen_win_info *win_info,
     {
       for (i = index_start; (i < num_elements + index_start); i++)
 	{
-	  if ((element_ptr = XMALLOC (struct tui_win_element)) != NULL)
+	  if ((element_ptr = XNEW (struct tui_win_element)) != NULL)
 	    {
 	      win_info->content[i] = (void *) element_ptr;
 	      init_content_element (element_ptr, win_info->type);
diff --git a/gdb/tui/tui-file.c b/gdb/tui/tui-file.c
index c86e260..8e84fc5 100644
--- a/gdb/tui/tui-file.c
+++ b/gdb/tui/tui-file.c
@@ -57,7 +57,7 @@ static int tui_file_magic;
 static struct ui_file *
 tui_file_new (void)
 {
-  struct tui_stream *tui = XMALLOC (struct tui_stream);
+  struct tui_stream *tui = XNEW (struct tui_stream);
   struct ui_file *file = ui_file_new ();
 
   set_ui_file_data (file, tui, tui_file_delete);
diff --git a/gdb/tui/tui-out.c b/gdb/tui/tui-out.c
index 9e89419..44f76a2 100644
--- a/gdb/tui/tui-out.c
+++ b/gdb/tui/tui-out.c
@@ -150,7 +150,7 @@ tui_out_new (struct ui_file *stream)
 {
   int flags = 0;
 
-  tui_out_data *data = XMALLOC (tui_out_data);
+  tui_out_data *data = XNEW (tui_out_data);
 
   /* Initialize base "class".  */
   cli_out_data_ctor (&data->base, stream);
diff --git a/gdb/ui-file.c b/gdb/ui-file.c
index 4de5785..e59d70b 100644
--- a/gdb/ui-file.c
+++ b/gdb/ui-file.c
@@ -393,7 +393,7 @@ static int mem_file_magic;
 static struct ui_file *
 mem_file_new (void)
 {
-  struct mem_file *stream = XMALLOC (struct mem_file);
+  struct mem_file *stream = XNEW (struct mem_file);
   struct ui_file *file = ui_file_new ();
 
   set_ui_file_data (file, stream, mem_file_delete);
diff --git a/gdb/ui-out.c b/gdb/ui-out.c
index d0dc2f4..a591352 100644
--- a/gdb/ui-out.c
+++ b/gdb/ui-out.c
@@ -131,7 +131,7 @@ push_level (struct ui_out *uiout,
   struct ui_out_level *current;
 
   uiout->level++;
-  current = XMALLOC (struct ui_out_level);
+  current = XNEW (struct ui_out_level);
   current->field_count = 0;
   current->type = type;
   VEC_safe_push (ui_out_level_p, uiout->levels, current);
@@ -443,7 +443,7 @@ make_cleanup_ui_out_end (struct ui_out *uiout,
 {
   struct ui_out_end_cleanup_data *end_cleanup_data;
 
-  end_cleanup_data = XMALLOC (struct ui_out_end_cleanup_data);
+  end_cleanup_data = XNEW (struct ui_out_end_cleanup_data);
   end_cleanup_data->uiout = uiout;
   end_cleanup_data->type = type;
   return make_cleanup (do_cleanup_end, end_cleanup_data);
@@ -964,7 +964,7 @@ append_header_to_list (struct ui_out *uiout,
 {
   struct ui_out_hdr *temphdr;
 
-  temphdr = XMALLOC (struct ui_out_hdr);
+  temphdr = XNEW (struct ui_out_hdr);
   temphdr->width = width;
   temphdr->alignment = alignment;
   /* We have to copy the column title as the original may be an
@@ -1098,8 +1098,8 @@ struct ui_out *
 ui_out_new (struct ui_out_impl *impl, void *data,
 	    int flags)
 {
-  struct ui_out *uiout = XMALLOC (struct ui_out);
-  struct ui_out_level *current = XMALLOC (struct ui_out_level);
+  struct ui_out *uiout = XNEW (struct ui_out);
+  struct ui_out_level *current = XNEW (struct ui_out_level);
 
   uiout->data = data;
   uiout->impl = impl;
diff --git a/gdb/user-regs.c b/gdb/user-regs.c
index 480c968..db0cac8 100644
--- a/gdb/user-regs.c
+++ b/gdb/user-regs.c
@@ -85,7 +85,7 @@ user_reg_add_builtin (const char *name, user_reg_read_ftype *read,
 		      const void *baton)
 {
   append_user_reg (&builtin_user_regs, name, read, baton,
-		   XMALLOC (struct user_reg));
+		   XNEW (struct user_reg));
 }
 
 /* Per-architecture user registers.  Start with the builtin user
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/3] replace XZALLOC with XCNEW
  2014-01-06 17:32 [PATCH 0/3] remove overlapping allocation macros Tom Tromey
  2014-01-06 17:32 ` [PATCH 2/3] replace XMALLOC with XNEW Tom Tromey
  2014-01-06 17:32 ` [PATCH 3/3] replace XCALLOC with XCNEWVEC or XCNEW Tom Tromey
@ 2014-01-06 17:32 ` Tom Tromey
  2014-01-06 18:14 ` [PATCH 0/3] remove overlapping allocation macros Doug Evans
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Tom Tromey @ 2014-01-06 17:32 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This replaces XZALLOC with XCNEW and removes XZALLOC.
This change is purely mechanical.

2014-01-06  Tom Tromey  <tromey@redhat.com>

	* defs.h (XZALLOC): Remove.
	* ada-lang.c (get_ada_inferior_data): Use XCNEW, not XZALLOC.
	* ada-tasks.c (get_ada_tasks_pspace_data): Likewise.
	(get_ada_tasks_inferior_data): Likewise.
	* auto-load.c (get_auto_load_pspace_data): Likewise.
	* auxv.c (get_auxv_inferior_data): Likewise.
	* bfd-target.c (target_bfd_reopen): Likewise.
	* breakpoint.c (get_catch_syscall_inferior_data): Likewise.
	(deprecated_insert_raw_breakpoint): Likewise.
	* bsd-uthread.c (bsd_uthread_pid_to_str): Likewise.
	* corelow.c (core_open): Likewise.
	* darwin-nat.c (darwin_check_new_threads): Likewise.
	(darwin_attach_pid): Likewise.
	* dummy-frame.c (dummy_frame_push): Likewise.
	* dwarf2-frame.c (dwarf2_frame_cache): Likewise.
	* dwarf2loc.c (allocate_piece_closure): Likewise.
	* elfread.c (elf_symfile_segments): Likewise.
	* eval.c (ptrmath_type_p): Likewise.
	* exceptions.c (EXCEPTIONS_SIGJMP_BUF): Likewise.
	* gdbtypes.c (alloc_type_arch): Likewise.
	(alloc_type_instance): Likewise.
	* hppa-tdep.c (hppa_gdbarch_init): Likewise.
	* inf-child.c (inf_child_can_use_agent): Likewise.
	* inflow.c (get_inflow_inferior_data): Likewise.
	* infrun.c (save_infcall_suspend_state): Likewise.
	* jit.c (jit_reader_load): Likewise.
	(get_jit_objfile_data): Likewise.
	(get_jit_program_space_data): Likewise.
	(jit_object_open_impl): Likewise.
	(jit_symtab_open_impl): Likewise.
	(jit_block_open_impl): Likewise.
	(jit_frame_sniffer): Likewise.
	* linux-fork.c (add_fork): Likewise.
	* maint.c (make_command_stats_cleanup): Likewise.
	* objfiles.c (get_objfile_pspace_data): Likewise.
	* opencl-lang.c (struct lval_closure): Likewise.
	* osdata.c (osdata_start_osdata): Likewise.
	* progspace.c (new_address_space): Likewise.
	(add_program_space): Likewise.
	* remote-sim.c (get_sim_inferior_data): Likewise.
	* sh-tdep.c (sh_gdbarch_init): Likewise.
	* skip.c (Ignore): Likewise.
	(skip_delete_command): Likewise.
	* solib-aix.c (get_solib_aix_inferior_data): Likewise.
	(library_list_start_library): Likewise.
	(solib_aix_current_sos): Likewise.
	* solib-darwin.c (get_darwin_info): Likewise.
	(darwin_current_sos): Likewise.
	* solib-dsbt.c (get_dsbt_info): Likewise.
	* solib-ia64-hpux.c (new_so_list): Likewise.
	(ia64_hpux_get_solib_linkage_addr): Likewise.
	* solib-spu.c (append_ocl_sos): Likewise.
	(spu_current_sos): Likewise.
	* solib-svr4.c (get_svr4_info): Likewise.
	(svr4_keep_data_in_core): Likewise.
	(library_list_start_library): Likewise.
	(svr4_default_sos): Likewise.
	(svr4_read_so_list): Likewise.
	* solib-target.c (library_list_start_library): Likewise.
	(solib_target_current_sos): Likewise.
	* sparc-tdep.c (sparc32_gdbarch_init): Likewise.
	* symfile-debug.c (install_symfile_debug_logging): Likewise.
	* symfile.c (default_symfile_segments): Likewise.
	* target-descriptions.c (tdesc_data_init): Likewise.
	(tdesc_create_reg): Likewise.
	(struct tdesc_type *): Likewise.
	(tdesc_create_vector): Likewise.
	(tdesc_set_struct_size): Likewise.
	(struct tdesc_type *): Likewise.
	(tdesc_free_feature): Likewise.
	(tdesc_create_feature): Likewise.
	* windows-nat.c (windows_add_thread): Likewise.
	(windows_make_so): Likewise.
	* xml-support.c (gdb_xml_body_text): Likewise.
	(gdb_xml_create_parser_and_cleanup): Likewise.
	(xml_process_xincludes): Likewise.
	* xml-syscall.c (allocate_syscalls_info): Likewise.
	(syscall_create_syscall_desc): Likewise.
---
 gdb/ChangeLog             | 81 +++++++++++++++++++++++++++++++++++++++++++++++
 gdb/ada-lang.c            |  2 +-
 gdb/ada-tasks.c           |  4 +--
 gdb/auto-load.c           |  2 +-
 gdb/auxv.c                |  2 +-
 gdb/bfd-target.c          |  4 +--
 gdb/breakpoint.c          |  4 +--
 gdb/bsd-uthread.c         |  2 +-
 gdb/corelow.c             |  2 +-
 gdb/darwin-nat.c          |  4 +--
 gdb/defs.h                |  1 -
 gdb/dummy-frame.c         |  2 +-
 gdb/dwarf2-frame.c        |  2 +-
 gdb/dwarf2loc.c           |  2 +-
 gdb/elfread.c             |  2 +-
 gdb/eval.c                |  4 +--
 gdb/exceptions.c          |  2 +-
 gdb/gdbtypes.c            |  6 ++--
 gdb/hppa-tdep.c           |  2 +-
 gdb/inf-child.c           |  2 +-
 gdb/inflow.c              |  2 +-
 gdb/infrun.c              |  2 +-
 gdb/jit.c                 | 14 ++++----
 gdb/linux-fork.c          |  2 +-
 gdb/maint.c               |  2 +-
 gdb/objfiles.c            |  2 +-
 gdb/opencl-lang.c         |  2 +-
 gdb/osdata.c              |  2 +-
 gdb/progspace.c           |  4 +--
 gdb/remote-sim.c          |  2 +-
 gdb/sh-tdep.c             |  2 +-
 gdb/skip.c                |  4 +--
 gdb/solib-aix.c           |  6 ++--
 gdb/solib-darwin.c        |  4 +--
 gdb/solib-dsbt.c          |  2 +-
 gdb/solib-ia64-hpux.c     |  6 ++--
 gdb/solib-spu.c           |  4 +--
 gdb/solib-svr4.c          | 12 +++----
 gdb/solib-target.c        |  4 +--
 gdb/sparc-tdep.c          |  2 +-
 gdb/symfile-debug.c       |  2 +-
 gdb/symfile.c             |  2 +-
 gdb/target-descriptions.c | 16 +++++-----
 gdb/windows-nat.c         |  4 +--
 gdb/xml-support.c         |  6 ++--
 gdb/xml-syscall.c         |  4 +--
 46 files changed, 163 insertions(+), 83 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index c14b684..15f95b4 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -359,7 +359,7 @@ get_ada_inferior_data (struct inferior *inf)
   data = inferior_data (inf, ada_inferior_data);
   if (data == NULL)
     {
-      data = XZALLOC (struct ada_inferior_data);
+      data = XCNEW (struct ada_inferior_data);
       set_inferior_data (inf, ada_inferior_data, data);
     }
 
diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c
index 53a29e1..a83035f 100644
--- a/gdb/ada-tasks.c
+++ b/gdb/ada-tasks.c
@@ -251,7 +251,7 @@ get_ada_tasks_pspace_data (struct program_space *pspace)
   data = program_space_data (pspace, ada_tasks_pspace_data_handle);
   if (data == NULL)
     {
-      data = XZALLOC (struct ada_tasks_pspace_data);
+      data = XCNEW (struct ada_tasks_pspace_data);
       set_program_space_data (pspace, ada_tasks_pspace_data_handle, data);
     }
 
@@ -278,7 +278,7 @@ get_ada_tasks_inferior_data (struct inferior *inf)
   data = inferior_data (inf, ada_tasks_inferior_data_handle);
   if (data == NULL)
     {
-      data = XZALLOC (struct ada_tasks_inferior_data);
+      data = XCNEW (struct ada_tasks_inferior_data);
       set_inferior_data (inf, ada_tasks_inferior_data_handle, data);
     }
 
diff --git a/gdb/auto-load.c b/gdb/auto-load.c
index 4bb4ced..1618e13 100644
--- a/gdb/auto-load.c
+++ b/gdb/auto-load.c
@@ -596,7 +596,7 @@ get_auto_load_pspace_data (struct program_space *pspace)
   info = program_space_data (pspace, auto_load_pspace_data);
   if (info == NULL)
     {
-      info = XZALLOC (struct auto_load_pspace_info);
+      info = XCNEW (struct auto_load_pspace_info);
       set_program_space_data (pspace, auto_load_pspace_data, info);
     }
 
diff --git a/gdb/auxv.c b/gdb/auxv.c
index b08f1d5..6223de2 100644
--- a/gdb/auxv.c
+++ b/gdb/auxv.c
@@ -341,7 +341,7 @@ get_auxv_inferior_data (struct target_ops *ops)
   info = inferior_data (inf, auxv_inferior_data);
   if (info == NULL)
     {
-      info = XZALLOC (struct auxv_info);
+      info = XCNEW (struct auxv_info);
       info->length = target_read_alloc (ops, TARGET_OBJECT_AUXV,
 					NULL, &info->data);
       set_inferior_data (inf, auxv_inferior_data, info);
diff --git a/gdb/bfd-target.c b/gdb/bfd-target.c
index 4cbac20..559ca63 100644
--- a/gdb/bfd-target.c
+++ b/gdb/bfd-target.c
@@ -83,12 +83,12 @@ target_bfd_reopen (struct bfd *abfd)
   struct target_ops *t;
   struct target_bfd_data *data;
 
-  data = XZALLOC (struct target_bfd_data);
+  data = XCNEW (struct target_bfd_data);
   data->bfd = abfd;
   gdb_bfd_ref (abfd);
   build_section_table (abfd, &data->table.sections, &data->table.sections_end);
 
-  t = XZALLOC (struct target_ops);
+  t = XCNEW (struct target_ops);
   t->to_shortname = "bfd";
   t->to_longname = _("BFD backed target");
   t->to_doc = _("You should never see this");
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 114762d..e65f85e 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -8190,7 +8190,7 @@ get_catch_syscall_inferior_data (struct inferior *inf)
   inf_data = inferior_data (inf, catch_syscall_inferior_data);
   if (inf_data == NULL)
     {
-      inf_data = XZALLOC (struct catch_syscall_inferior_data);
+      inf_data = XCNEW (struct catch_syscall_inferior_data);
       set_inferior_data (inf, catch_syscall_inferior_data, inf_data);
     }
 
@@ -14946,7 +14946,7 @@ deprecated_insert_raw_breakpoint (struct gdbarch *gdbarch,
 {
   struct bp_target_info *bp_tgt;
 
-  bp_tgt = XZALLOC (struct bp_target_info);
+  bp_tgt = XCNEW (struct bp_target_info);
 
   bp_tgt->placed_address_space = aspace;
   bp_tgt->placed_address = pc;
diff --git a/gdb/bsd-uthread.c b/gdb/bsd-uthread.c
index 5757e77..af522fa 100644
--- a/gdb/bsd-uthread.c
+++ b/gdb/bsd-uthread.c
@@ -518,7 +518,7 @@ bsd_uthread_pid_to_str (struct target_ops *ops, ptid_t ptid)
 static struct target_ops *
 bsd_uthread_target (void)
 {
-  struct target_ops *t = XZALLOC (struct target_ops);
+  struct target_ops *t = XCNEW (struct target_ops);
 
   t->to_shortname = "bsd-uthreads";
   t->to_longname = "BSD user-level threads";
diff --git a/gdb/corelow.c b/gdb/corelow.c
index 7183f62..8b20d3f 100644
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -348,7 +348,7 @@ core_open (char *filename, int from_tty)
 
   validate_files ();
 
-  core_data = XZALLOC (struct target_section_table);
+  core_data = XCNEW (struct target_section_table);
 
   /* Find the data section */
   if (build_section_table (core_bfd,
diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
index a21bb0f..f0935a6 100644
--- a/gdb/darwin-nat.c
+++ b/gdb/darwin-nat.c
@@ -350,7 +350,7 @@ darwin_check_new_threads (struct inferior *inf)
 	  struct thread_info *tp;
 	  struct private_thread_info *pti;
 
-	  pti = XZALLOC (struct private_thread_info);
+	  pti = XCNEW (struct private_thread_info);
 	  pti->gdb_port = new_id;
 	  pti->msg_state = DARWIN_RUNNING;
 
@@ -1344,7 +1344,7 @@ darwin_attach_pid (struct inferior *inf)
   mach_port_t prev_not;
   exception_mask_t mask;
 
-  inf->private = XZALLOC (darwin_inferior);
+  inf->private = XCNEW (darwin_inferior);
 
   kret = task_for_pid (gdb_task, inf->pid, &inf->private->task);
   if (kret != KERN_SUCCESS)
diff --git a/gdb/defs.h b/gdb/defs.h
index f3f034f..4c70cf6 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -556,7 +556,6 @@ extern int longest_to_int (LONGEST);
 /* Utility macros to allocate typed memory.  Avoids errors like:
    struct foo *foo = xmalloc (sizeof struct bar); and memset (foo,
    sizeof (struct foo), 0).  */
-#define XZALLOC(TYPE) ((TYPE*) xzalloc (sizeof (TYPE)))
 #define XMALLOC(TYPE) ((TYPE*) xmalloc (sizeof (TYPE)))
 #define XCALLOC(NMEMB, TYPE) ((TYPE*) xcalloc ((NMEMB), sizeof (TYPE)))
 
diff --git a/gdb/dummy-frame.c b/gdb/dummy-frame.c
index 390b4c9..998ca93 100644
--- a/gdb/dummy-frame.c
+++ b/gdb/dummy-frame.c
@@ -56,7 +56,7 @@ dummy_frame_push (struct infcall_suspend_state *caller_state,
 {
   struct dummy_frame *dummy_frame;
 
-  dummy_frame = XZALLOC (struct dummy_frame);
+  dummy_frame = XCNEW (struct dummy_frame);
   dummy_frame->caller_state = caller_state;
   dummy_frame->id = (*dummy_id);
   dummy_frame->next = dummy_frame_stack;
diff --git a/gdb/dwarf2-frame.c b/gdb/dwarf2-frame.c
index 1907128..3dcaf27 100644
--- a/gdb/dwarf2-frame.c
+++ b/gdb/dwarf2-frame.c
@@ -1045,7 +1045,7 @@ dwarf2_frame_cache (struct frame_info *this_frame, void **this_cache)
   reset_cache_cleanup = make_cleanup (clear_pointer_cleanup, this_cache);
 
   /* Allocate and initialize the frame state.  */
-  fs = XZALLOC (struct dwarf2_frame_state);
+  fs = XCNEW (struct dwarf2_frame_state);
   old_chain = make_cleanup (dwarf2_frame_state_free, fs);
 
   /* Unwind the PC.
diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
index dd921ec..6185a6b 100644
--- a/gdb/dwarf2loc.c
+++ b/gdb/dwarf2loc.c
@@ -1414,7 +1414,7 @@ allocate_piece_closure (struct dwarf2_per_cu_data *per_cu,
 			int n_pieces, struct dwarf_expr_piece *pieces,
 			int addr_size)
 {
-  struct piece_closure *c = XZALLOC (struct piece_closure);
+  struct piece_closure *c = XCNEW (struct piece_closure);
   int i;
 
   c->refc = 1;
diff --git a/gdb/elfread.c b/gdb/elfread.c
index 31f6470..4f27aff 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -105,7 +105,7 @@ elf_symfile_segments (bfd *abfd)
   if (num_segments == 0)
     return NULL;
 
-  data = XZALLOC (struct symfile_segment_data);
+  data = XCNEW (struct symfile_segment_data);
   data->num_segments = num_segments;
   data->segment_bases = XCALLOC (num_segments, CORE_ADDR);
   data->segment_sizes = XCALLOC (num_segments, CORE_ADDR);
diff --git a/gdb/eval.c b/gdb/eval.c
index bfbe319..949f76c 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -660,8 +660,8 @@ ptrmath_type_p (const struct language_defn *lang, struct type *type)
 static struct type *
 make_params (int num_types, struct type **param_types)
 {
-  struct type *type = XZALLOC (struct type);
-  TYPE_MAIN_TYPE (type) = XZALLOC (struct main_type);
+  struct type *type = XCNEW (struct type);
+  TYPE_MAIN_TYPE (type) = XCNEW (struct main_type);
   TYPE_LENGTH (type) = 1;
   TYPE_CODE (type) = TYPE_CODE_METHOD;
   TYPE_VPTR_FIELDNO (type) = -1;
diff --git a/gdb/exceptions.c b/gdb/exceptions.c
index b0b6c97..ca80893 100644
--- a/gdb/exceptions.c
+++ b/gdb/exceptions.c
@@ -86,7 +86,7 @@ EXCEPTIONS_SIGJMP_BUF *
 exceptions_state_mc_init (volatile struct gdb_exception *exception,
 			  return_mask mask)
 {
-  struct catcher *new_catcher = XZALLOC (struct catcher);
+  struct catcher *new_catcher = XCNEW (struct catcher);
 
   /* Start with no exception, save it's address.  */
   exception->reason = 0;
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 8e3090d..e02b66c 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -201,8 +201,8 @@ alloc_type_arch (struct gdbarch *gdbarch)
 
   /* Alloc the structure and start off with all fields zeroed.  */
 
-  type = XZALLOC (struct type);
-  TYPE_MAIN_TYPE (type) = XZALLOC (struct main_type);
+  type = XCNEW (struct type);
+  TYPE_MAIN_TYPE (type) = XCNEW (struct main_type);
 
   TYPE_OBJFILE_OWNED (type) = 0;
   TYPE_OWNER (type).gdbarch = gdbarch;
@@ -268,7 +268,7 @@ alloc_type_instance (struct type *oldtype)
   /* Allocate the structure.  */
 
   if (! TYPE_OBJFILE_OWNED (oldtype))
-    type = XZALLOC (struct type);
+    type = XCNEW (struct type);
   else
     type = OBSTACK_ZALLOC (&TYPE_OBJFILE (oldtype)->objfile_obstack,
 			   struct type);
diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c
index 68ec9cf..53b6c95 100644
--- a/gdb/hppa-tdep.c
+++ b/gdb/hppa-tdep.c
@@ -2997,7 +2997,7 @@ hppa_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
     return (arches->gdbarch);
 
   /* If none found, then allocate and initialize one.  */
-  tdep = XZALLOC (struct gdbarch_tdep);
+  tdep = XCNEW (struct gdbarch_tdep);
   gdbarch = gdbarch_alloc (&info, tdep);
 
   /* Determine from the bfd_arch_info structure if we are dealing with
diff --git a/gdb/inf-child.c b/gdb/inf-child.c
index d722509..75944a0 100644
--- a/gdb/inf-child.c
+++ b/gdb/inf-child.c
@@ -386,7 +386,7 @@ inf_child_can_use_agent (void)
 struct target_ops *
 inf_child_target (void)
 {
-  struct target_ops *t = XZALLOC (struct target_ops);
+  struct target_ops *t = XCNEW (struct target_ops);
 
   t->to_shortname = "child";
   t->to_longname = "Unix child process";
diff --git a/gdb/inflow.c b/gdb/inflow.c
index 9e2444c..5503a42 100644
--- a/gdb/inflow.c
+++ b/gdb/inflow.c
@@ -505,7 +505,7 @@ get_inflow_inferior_data (struct inferior *inf)
   info = inferior_data (inf, inflow_inferior_data);
   if (info == NULL)
     {
-      info = XZALLOC (struct terminal_info);
+      info = XCNEW (struct terminal_info);
       set_inferior_data (inf, inflow_inferior_data, info);
     }
 
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 51540b3..73038a3 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -6851,7 +6851,7 @@ save_infcall_suspend_state (void)
 	}
     }
 
-  inf_state = XZALLOC (struct infcall_suspend_state);
+  inf_state = XCNEW (struct infcall_suspend_state);
 
   if (siginfo_data)
     {
diff --git a/gdb/jit.c b/gdb/jit.c
index 033a370..59823a5 100644
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -189,7 +189,7 @@ jit_reader_load (const char *file_name)
   if (funcs->reader_version != GDB_READER_INTERFACE_VERSION)
     error (_("Reader version does not match GDB version."));
 
-  new_reader = XZALLOC (struct jit_reader);
+  new_reader = XCNEW (struct jit_reader);
   new_reader->functions = funcs;
   new_reader->handle = so;
 
@@ -288,7 +288,7 @@ get_jit_objfile_data (struct objfile *objf)
   objf_data = objfile_data (objf, jit_objfile_data);
   if (objf_data == NULL)
     {
-      objf_data = XZALLOC (struct jit_objfile_data);
+      objf_data = XCNEW (struct jit_objfile_data);
       set_objfile_data (objf, jit_objfile_data, objf_data);
     }
 
@@ -318,7 +318,7 @@ get_jit_program_space_data (void)
   ps_data = program_space_data (current_program_space, jit_program_space_data);
   if (ps_data == NULL)
     {
-      ps_data = XZALLOC (struct jit_program_space_data);
+      ps_data = XCNEW (struct jit_program_space_data);
       set_program_space_data (current_program_space, jit_program_space_data,
 			      ps_data);
     }
@@ -504,7 +504,7 @@ jit_object_open_impl (struct gdb_symbol_callbacks *cb)
   /* CB is not required right now, but sometime in the future we might
      need a handle to it, and we'd like to do that without breaking
      the ABI.  */
-  return XZALLOC (struct gdb_object);
+  return XCNEW (struct gdb_object);
 }
 
 /* Readers call into this function to open a new gdb_symtab, which,
@@ -519,7 +519,7 @@ jit_symtab_open_impl (struct gdb_symbol_callbacks *cb,
 
   /* CB stays unused.  See comment in jit_object_open_impl.  */
 
-  ret = XZALLOC (struct gdb_symtab);
+  ret = XCNEW (struct gdb_symtab);
   ret->file_name = file_name ? xstrdup (file_name) : xstrdup ("");
   ret->next = object->symtabs;
   object->symtabs = ret;
@@ -557,7 +557,7 @@ jit_block_open_impl (struct gdb_symbol_callbacks *cb,
                      struct gdb_symtab *symtab, struct gdb_block *parent,
                      GDB_CORE_ADDR begin, GDB_CORE_ADDR end, const char *name)
 {
-  struct gdb_block *block = XZALLOC (struct gdb_block);
+  struct gdb_block *block = XCNEW (struct gdb_block);
 
   block->next = symtab->blocks;
   block->begin = (CORE_ADDR) begin;
@@ -1181,7 +1181,7 @@ jit_frame_sniffer (const struct frame_unwind *self,
 
   gdb_assert (!*cache);
 
-  *cache = XZALLOC (struct jit_unwind_private);
+  *cache = XCNEW (struct jit_unwind_private);
   priv_data = *cache;
   priv_data->registers =
     XCALLOC (gdbarch_num_regs (get_frame_arch (this_frame)),
diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c
index f8afd4a..cfe1ce5 100644
--- a/gdb/linux-fork.c
+++ b/gdb/linux-fork.c
@@ -81,7 +81,7 @@ add_fork (pid_t pid)
       add_fork (ptid_get_pid (inferior_ptid));	/* safe recursion */
     }
 
-  fp = XZALLOC (struct fork_info);
+  fp = XCNEW (struct fork_info);
   fp->ptid = ptid_build (pid, pid, 0);
   fp->num = ++highest_fork_num;
   fp->next = fork_list;
diff --git a/gdb/maint.c b/gdb/maint.c
index df8a8fe..41a39e7 100644
--- a/gdb/maint.c
+++ b/gdb/maint.c
@@ -902,7 +902,7 @@ make_command_stats_cleanup (int msg_type)
       && !per_command_symtab)
     return make_cleanup (null_cleanup, 0);
 
-  new_stat = XZALLOC (struct cmd_stats);
+  new_stat = XCNEW (struct cmd_stats);
 
   new_stat->msg_type = msg_type;
 
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 73847bd..9cc0054 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -102,7 +102,7 @@ get_objfile_pspace_data (struct program_space *pspace)
   info = program_space_data (pspace, objfiles_pspace_data);
   if (info == NULL)
     {
-      info = XZALLOC (struct objfile_pspace_info);
+      info = XCNEW (struct objfile_pspace_info);
       set_program_space_data (pspace, objfiles_pspace_data, info);
     }
 
diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c
index f098b3f..4327fe6 100644
--- a/gdb/opencl-lang.c
+++ b/gdb/opencl-lang.c
@@ -157,7 +157,7 @@ struct lval_closure
 static struct lval_closure *
 allocate_lval_closure (int *indices, int n, struct value *val)
 {
-  struct lval_closure *c = XZALLOC (struct lval_closure);
+  struct lval_closure *c = XCNEW (struct lval_closure);
 
   c->refc = 1;
   c->n = n;
diff --git a/gdb/osdata.c b/gdb/osdata.c
index 467e2f1..da9bfac 100644
--- a/gdb/osdata.c
+++ b/gdb/osdata.c
@@ -69,7 +69,7 @@ osdata_start_osdata (struct gdb_xml_parser *parser,
     gdb_xml_error (parser, _("Seen more than on osdata element"));
 
   type = xml_find_attribute (attributes, "type")->value;
-  osdata = XZALLOC (struct osdata);
+  osdata = XCNEW (struct osdata);
   osdata->type = xstrdup (type);
   data->osdata = osdata;
 }
diff --git a/gdb/progspace.c b/gdb/progspace.c
index 9a6321f..14507ef 100644
--- a/gdb/progspace.c
+++ b/gdb/progspace.c
@@ -70,7 +70,7 @@ new_address_space (void)
 {
   struct address_space *aspace;
 
-  aspace = XZALLOC (struct address_space);
+  aspace = XCNEW (struct address_space);
   aspace->num = ++highest_address_space_num;
   address_space_alloc_data (aspace);
 
@@ -126,7 +126,7 @@ add_program_space (struct address_space *aspace)
 {
   struct program_space *pspace;
 
-  pspace = XZALLOC (struct program_space);
+  pspace = XCNEW (struct program_space);
 
   pspace->num = ++last_program_space_num;
   pspace->aspace = aspace;
diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c
index b0f4922..7263727 100644
--- a/gdb/remote-sim.c
+++ b/gdb/remote-sim.c
@@ -206,7 +206,7 @@ get_sim_inferior_data (struct inferior *inf, int sim_instance_needed)
 
   if (sim_data == NULL)
     {
-      sim_data = XZALLOC(struct sim_inferior_data);
+      sim_data = XCNEW(struct sim_inferior_data);
       set_inferior_data (inf, sim_inferior_data_key, sim_data);
 
       /* Allocate a ptid for this inferior.  */
diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c
index 6bfd041..85f8067 100644
--- a/gdb/sh-tdep.c
+++ b/gdb/sh-tdep.c
@@ -2253,7 +2253,7 @@ sh_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   /* None found, create a new architecture from the information
      provided.  */
-  tdep = XZALLOC (struct gdbarch_tdep);
+  tdep = XCNEW (struct gdbarch_tdep);
   gdbarch = gdbarch_alloc (&info, tdep);
 
   set_gdbarch_short_bit (gdbarch, 2 * TARGET_CHAR_BIT);
diff --git a/gdb/skip.c b/gdb/skip.c
index 5aadb73..64a0254 100644
--- a/gdb/skip.c
+++ b/gdb/skip.c
@@ -101,7 +101,7 @@ Ignore file pending future shared library load? ")))
       filename = arg;
     }
 
-  e = XZALLOC (struct skiplist_entry);
+  e = XCNEW (struct skiplist_entry);
   e->filename = xstrdup (filename);
   e->enabled = 1;
 
@@ -295,7 +295,7 @@ skip_delete_command (char *arg, int from_tty)
 static void
 skip_function (const char *name)
 {
-  struct skiplist_entry *e = XZALLOC (struct skiplist_entry);
+  struct skiplist_entry *e = XCNEW (struct skiplist_entry);
 
   e->enabled = 1;
   e->function_name = xstrdup (name);
diff --git a/gdb/solib-aix.c b/gdb/solib-aix.c
index fefa51f..8f335f6 100644
--- a/gdb/solib-aix.c
+++ b/gdb/solib-aix.c
@@ -115,7 +115,7 @@ get_solib_aix_inferior_data (struct inferior *inf)
   data = inferior_data (inf, solib_aix_inferior_data_handle);
   if (data == NULL)
     {
-      data = XZALLOC (struct solib_aix_inferior_data);
+      data = XCNEW (struct solib_aix_inferior_data);
       set_inferior_data (inf, solib_aix_inferior_data_handle, data);
     }
 
@@ -161,7 +161,7 @@ library_list_start_library (struct gdb_xml_parser *parser,
 			    VEC (gdb_xml_value_s) *attributes)
 {
   VEC (lm_info_p) **list = user_data;
-  struct lm_info *item = XZALLOC (struct lm_info);
+  struct lm_info *item = XCNEW (struct lm_info);
   struct gdb_xml_value *attr;
 
   attr = xml_find_attribute (attributes, "name");
@@ -575,7 +575,7 @@ solib_aix_current_sos (void)
      to the main executable, not a shared library.  */
   for (ix = 1; VEC_iterate (lm_info_p, library_list, ix, info); ix++)
     {
-      struct so_list *new_solib = XZALLOC (struct so_list);
+      struct so_list *new_solib = XCNEW (struct so_list);
       char *so_name;
 
       if (info->member_name == NULL)
diff --git a/gdb/solib-darwin.c b/gdb/solib-darwin.c
index ba807a2..e8d4667 100644
--- a/gdb/solib-darwin.c
+++ b/gdb/solib-darwin.c
@@ -103,7 +103,7 @@ get_darwin_info (void)
   if (info != NULL)
     return info;
 
-  info = XZALLOC (struct darwin_info);
+  info = XCNEW (struct darwin_info);
   set_program_space_data (current_program_space,
 			  solib_darwin_pspace_data, info);
   return info;
@@ -304,7 +304,7 @@ darwin_current_sos (void)
 	break;
 
       /* Create and fill the new so_list element.  */
-      dnew = XZALLOC (struct darwin_so_list);
+      dnew = XCNEW (struct darwin_so_list);
       new = &dnew->sl;
       old_chain = make_cleanup (xfree, dnew);
 
diff --git a/gdb/solib-dsbt.c b/gdb/solib-dsbt.c
index 075c92e..713fa51 100644
--- a/gdb/solib-dsbt.c
+++ b/gdb/solib-dsbt.c
@@ -181,7 +181,7 @@ get_dsbt_info (void)
   if (info != NULL)
     return info;
 
-  info = XZALLOC (struct dsbt_info);
+  info = XCNEW (struct dsbt_info);
   set_program_space_data (current_program_space, solib_dsbt_pspace_data, info);
 
   info->lm_base_cache = 0;
diff --git a/gdb/solib-ia64-hpux.c b/gdb/solib-ia64-hpux.c
index d91b2a1..b53caa8 100644
--- a/gdb/solib-ia64-hpux.c
+++ b/gdb/solib-ia64-hpux.c
@@ -86,8 +86,8 @@ new_so_list (char *so_name, struct load_module_desc module_desc)
 {
   struct so_list *new_so;
 
-  new_so = (struct so_list *) XZALLOC (struct so_list);
-  new_so->lm_info = (struct lm_info *) XZALLOC (struct lm_info);
+  new_so = (struct so_list *) XCNEW (struct so_list);
+  new_so->lm_info = (struct lm_info *) XCNEW (struct lm_info);
   new_so->lm_info->module_desc = module_desc;
 
   strncpy (new_so->so_name, so_name, SO_NAME_MAX_PATH_SIZE - 1);
@@ -677,7 +677,7 @@ ia64_hpux_get_solib_linkage_addr (CORE_ADDR faddr)
 static struct target_so_ops *
 ia64_hpux_target_so_ops (void)
 {
-  struct target_so_ops *ops = XZALLOC (struct target_so_ops);
+  struct target_so_ops *ops = XCNEW (struct target_so_ops);
 
   ops->relocate_section_addresses = ia64_hpux_relocate_section_addresses;
   ops->free_so = ia64_hpux_free_so;
diff --git a/gdb/solib-spu.c b/gdb/solib-spu.c
index abb8c15..b8e5e23 100644
--- a/gdb/solib-spu.c
+++ b/gdb/solib-spu.c
@@ -125,7 +125,7 @@ append_ocl_sos (struct so_list **link_ptr)
 		  struct so_list *new;
 
 		  /* Allocate so_list structure.  */
-		  new = XZALLOC (struct so_list);
+		  new = XCNEW (struct so_list);
 
 		  /* Encode FD and object ID in path name.  */
 		  xsnprintf (new->so_name, sizeof new->so_name, "@%s <%d>",
@@ -217,7 +217,7 @@ spu_current_sos (void)
 	continue;
 
       /* Allocate so_list structure.  */
-      new = XZALLOC (struct so_list);
+      new = XCNEW (struct so_list);
 
       /* Encode FD and object ID in path name.  Choose the name so as not
 	 to conflict with any (normal) SVR4 library path name.  */
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index cf9d651..55572d4 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -427,7 +427,7 @@ get_svr4_info (void)
   if (info != NULL)
     return info;
 
-  info = XZALLOC (struct svr4_info);
+  info = XCNEW (struct svr4_info);
   set_program_space_data (current_program_space, solib_svr4_pspace_data, info);
   return info;
 }
@@ -949,7 +949,7 @@ svr4_keep_data_in_core (CORE_ADDR vaddr, unsigned long size)
   if (!ldsomap)
     return 0;
 
-  new = XZALLOC (struct so_list);
+  new = XCNEW (struct so_list);
   old_chain = make_cleanup (xfree, new);
   new->lm_info = lm_info_read (ldsomap);
   make_cleanup (xfree, new->lm_info);
@@ -1126,8 +1126,8 @@ library_list_start_library (struct gdb_xml_parser *parser,
   ULONGEST *l_ldp = xml_find_attribute (attributes, "l_ld")->value;
   struct so_list *new_elem;
 
-  new_elem = XZALLOC (struct so_list);
-  new_elem->lm_info = XZALLOC (struct lm_info);
+  new_elem = XCNEW (struct so_list);
+  new_elem->lm_info = XCNEW (struct lm_info);
   new_elem->lm_info->lm_addr = *lmp;
   new_elem->lm_info->l_addr_inferior = *l_addrp;
   new_elem->lm_info->l_ld = *l_ldp;
@@ -1279,7 +1279,7 @@ svr4_default_sos (void)
   if (!info->debug_loader_offset_p)
     return NULL;
 
-  new = XZALLOC (struct so_list);
+  new = XCNEW (struct so_list);
 
   new->lm_info = xzalloc (sizeof (struct lm_info));
 
@@ -1316,7 +1316,7 @@ svr4_read_so_list (CORE_ADDR lm, CORE_ADDR prev_lm,
       int errcode;
       char *buffer;
 
-      new = XZALLOC (struct so_list);
+      new = XCNEW (struct so_list);
       old_chain = make_cleanup_free_so (new);
 
       new->lm_info = lm_info_read (lm);
diff --git a/gdb/solib-target.c b/gdb/solib-target.c
index fb12934..bb34e4b 100644
--- a/gdb/solib-target.c
+++ b/gdb/solib-target.c
@@ -119,7 +119,7 @@ library_list_start_library (struct gdb_xml_parser *parser,
 			    void *user_data, VEC(gdb_xml_value_s) *attributes)
 {
   VEC(lm_info_p) **list = user_data;
-  struct lm_info *item = XZALLOC (struct lm_info);
+  struct lm_info *item = XCNEW (struct lm_info);
   const char *name = xml_find_attribute (attributes, "name")->value;
 
   item->name = xstrdup (name);
@@ -274,7 +274,7 @@ solib_target_current_sos (void)
   /* Build a struct so_list for each entry on the list.  */
   for (ix = 0; VEC_iterate (lm_info_p, library_list, ix, info); ix++)
     {
-      new_solib = XZALLOC (struct so_list);
+      new_solib = XCNEW (struct so_list);
       strncpy (new_solib->so_name, info->name, SO_NAME_MAX_PATH_SIZE - 1);
       new_solib->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0';
       strncpy (new_solib->so_original_name, info->name,
diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c
index 66ef84e..38b345b 100644
--- a/gdb/sparc-tdep.c
+++ b/gdb/sparc-tdep.c
@@ -1653,7 +1653,7 @@ sparc32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
     return arches->gdbarch;
 
   /* Allocate space for the new architecture.  */
-  tdep = XZALLOC (struct gdbarch_tdep);
+  tdep = XCNEW (struct gdbarch_tdep);
   gdbarch = gdbarch_alloc (&info, tdep);
 
   tdep->pc_regnum = SPARC32_PC_REGNUM;
diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c
index 57d4af0..705d9cb 100644
--- a/gdb/symfile-debug.c
+++ b/gdb/symfile-debug.c
@@ -575,7 +575,7 @@ install_symfile_debug_logging (struct objfile *objfile)
   real_sf = objfile->sf;
 
   /* Alas we have to preserve NULL entries in REAL_SF.  */
-  debug_data = XZALLOC (struct debug_sym_fns_data);
+  debug_data = XCNEW (struct debug_sym_fns_data);
 
 #define COPY_SF_PTR(from, to, name, func)	\
   do {						\
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 4f0fea8..75e71cb 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -800,7 +800,7 @@ default_symfile_segments (bfd *abfd)
   low = bfd_get_section_vma (abfd, sect);
   high = low + bfd_get_section_size (sect);
 
-  data = XZALLOC (struct symfile_segment_data);
+  data = XCNEW (struct symfile_segment_data);
   data->num_segments = 1;
   data->segment_bases = XCALLOC (1, CORE_ADDR);
   data->segment_sizes = XCALLOC (1, CORE_ADDR);
diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
index 9147dbe..953748b 100644
--- a/gdb/target-descriptions.c
+++ b/gdb/target-descriptions.c
@@ -804,7 +804,7 @@ tdesc_data_init (struct obstack *obstack)
 struct tdesc_arch_data *
 tdesc_data_alloc (void)
 {
-  return XZALLOC (struct tdesc_arch_data);
+  return XCNEW (struct tdesc_arch_data);
 }
 
 /* Free something allocated by tdesc_data_alloc, if it is not going
@@ -1242,7 +1242,7 @@ tdesc_create_reg (struct tdesc_feature *feature, const char *name,
 		  int regnum, int save_restore, const char *group,
 		  int bitsize, const char *type)
 {
-  struct tdesc_reg *reg = XZALLOC (struct tdesc_reg);
+  struct tdesc_reg *reg = XCNEW (struct tdesc_reg);
 
   reg->name = xstrdup (name);
   reg->target_regnum = regnum;
@@ -1304,7 +1304,7 @@ struct tdesc_type *
 tdesc_create_vector (struct tdesc_feature *feature, const char *name,
 		     struct tdesc_type *field_type, int count)
 {
-  struct tdesc_type *type = XZALLOC (struct tdesc_type);
+  struct tdesc_type *type = XCNEW (struct tdesc_type);
 
   type->name = xstrdup (name);
   type->kind = TDESC_TYPE_VECTOR;
@@ -1318,7 +1318,7 @@ tdesc_create_vector (struct tdesc_feature *feature, const char *name,
 struct tdesc_type *
 tdesc_create_struct (struct tdesc_feature *feature, const char *name)
 {
-  struct tdesc_type *type = XZALLOC (struct tdesc_type);
+  struct tdesc_type *type = XCNEW (struct tdesc_type);
 
   type->name = xstrdup (name);
   type->kind = TDESC_TYPE_STRUCT;
@@ -1341,7 +1341,7 @@ tdesc_set_struct_size (struct tdesc_type *type, LONGEST size)
 struct tdesc_type *
 tdesc_create_union (struct tdesc_feature *feature, const char *name)
 {
-  struct tdesc_type *type = XZALLOC (struct tdesc_type);
+  struct tdesc_type *type = XCNEW (struct tdesc_type);
 
   type->name = xstrdup (name);
   type->kind = TDESC_TYPE_UNION;
@@ -1354,7 +1354,7 @@ struct tdesc_type *
 tdesc_create_flags (struct tdesc_feature *feature, const char *name,
 		    LONGEST size)
 {
-  struct tdesc_type *type = XZALLOC (struct tdesc_type);
+  struct tdesc_type *type = XCNEW (struct tdesc_type);
 
   type->name = xstrdup (name);
   type->kind = TDESC_TYPE_FLAGS;
@@ -1436,7 +1436,7 @@ tdesc_free_feature (struct tdesc_feature *feature)
 struct tdesc_feature *
 tdesc_create_feature (struct target_desc *tdesc, const char *name)
 {
-  struct tdesc_feature *new_feature = XZALLOC (struct tdesc_feature);
+  struct tdesc_feature *new_feature = XCNEW (struct tdesc_feature);
 
   new_feature->name = xstrdup (name);
 
@@ -1447,7 +1447,7 @@ tdesc_create_feature (struct target_desc *tdesc, const char *name)
 struct target_desc *
 allocate_target_description (void)
 {
-  return XZALLOC (struct target_desc);
+  return XCNEW (struct target_desc);
 }
 
 static void
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index b57adaa..bcc129b 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -342,7 +342,7 @@ windows_add_thread (ptid_t ptid, HANDLE h, void *tlb)
   if ((th = thread_rec (id, FALSE)))
     return th;
 
-  th = XZALLOC (thread_info);
+  th = XCNEW (thread_info);
   th->id = id;
   th->h = h;
   th->thread_local_base = (CORE_ADDR) (uintptr_t) tlb;
@@ -729,7 +729,7 @@ windows_make_so (const char *name, LPVOID load_addr)
 #endif
     }
 #endif
-  so = XZALLOC (struct so_list);
+  so = XCNEW (struct so_list);
   so->lm_info = (struct lm_info *) xmalloc (sizeof (struct lm_info));
   so->lm_info->load_addr = load_addr;
   strcpy (so->so_original_name, name);
diff --git a/gdb/xml-support.c b/gdb/xml-support.c
index 5d058b4..5062bc1 100644
--- a/gdb/xml-support.c
+++ b/gdb/xml-support.c
@@ -94,7 +94,7 @@ gdb_xml_body_text (void *data, const XML_Char *text, int length)
 
   if (scope->body == NULL)
     {
-      scope->body = XZALLOC (struct obstack);
+      scope->body = XCNEW (struct obstack);
       obstack_init (scope->body);
     }
 
@@ -454,7 +454,7 @@ gdb_xml_create_parser_and_cleanup (const char *name,
   struct cleanup *result;
 
   /* Initialize the parser.  */
-  parser = XZALLOC (struct gdb_xml_parser);
+  parser = XCNEW (struct gdb_xml_parser);
   parser->expat_parser = XML_ParserCreateNS (NULL, '!');
   if (parser->expat_parser == NULL)
     {
@@ -877,7 +877,7 @@ xml_process_xincludes (const char *name, const char *text,
   struct cleanup *back_to;
   char *result = NULL;
 
-  data = XZALLOC (struct xinclude_parsing_data);
+  data = XCNEW (struct xinclude_parsing_data);
   obstack_init (&data->obstack);
   back_to = make_cleanup (xml_xinclude_cleanup, data);
 
diff --git a/gdb/xml-syscall.c b/gdb/xml-syscall.c
index 986b75c..31d4ae6 100644
--- a/gdb/xml-syscall.c
+++ b/gdb/xml-syscall.c
@@ -126,7 +126,7 @@ static const char *xml_syscall_file = NULL;
 static struct syscalls_info *
 allocate_syscalls_info (void)
 {
-  return XZALLOC (struct syscalls_info);
+  return XCNEW (struct syscalls_info);
 }
 
 static void
@@ -161,7 +161,7 @@ static void
 syscall_create_syscall_desc (struct syscalls_info *sysinfo,
                              const char *name, int number)
 {
-  struct syscall_desc *sysdesc = XZALLOC (struct syscall_desc);
+  struct syscall_desc *sysdesc = XCNEW (struct syscall_desc);
 
   sysdesc->name = xstrdup (name);
   sysdesc->number = number;
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/3] remove overlapping allocation macros
  2014-01-06 17:32 [PATCH 0/3] remove overlapping allocation macros Tom Tromey
                   ` (2 preceding siblings ...)
  2014-01-06 17:32 ` [PATCH 1/3] replace XZALLOC with XCNEW Tom Tromey
@ 2014-01-06 18:14 ` Doug Evans
  2014-01-06 18:46 ` Pedro Alves
  2014-01-13 14:33 ` Tom Tromey
  5 siblings, 0 replies; 8+ messages in thread
From: Doug Evans @ 2014-01-06 18:14 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On Mon, Jan 6, 2014 at 9:32 AM, Tom Tromey <tromey@redhat.com> wrote:
> Right now, gdb defines some allocation macros in defs.h, specifically
> XZALLOC, XMALLOC, and XCALLOC.  libiberty also defines similar
> allocation macros, and gdb uses both variants.
>
> I think it's somewhat nicer if gdb uses just a single set of wrapper
> macros, and so this patch series replaces all the uses of the gdb
> macros with the corresponding macros from libiberty.
>
> Let me know what you think.
>
> Tested by rebuilding on x86-64 Fedora 18 and doing a cross build to
> mingw.  It's possible therefore that there are some buglets remaining.

I'm all for the increased simplicity.
I just wish libiberty's macro naming didn't suck so badly.
[Not necessarily a fault at the time, but it sucks now. :-)]

E.g., after this series, "vec" use to have a more specific connotation,
(I could at least ignore libiberty's choice),
and I hate it when terms with good specific connotations get polluted.
There's a material downgrade in the readability of the code when
that happens.

Fortunately, I guess this will only be a temporary material downgrade,
since vec -> stl::vector soon.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/3] remove overlapping allocation macros
  2014-01-06 17:32 [PATCH 0/3] remove overlapping allocation macros Tom Tromey
                   ` (3 preceding siblings ...)
  2014-01-06 18:14 ` [PATCH 0/3] remove overlapping allocation macros Doug Evans
@ 2014-01-06 18:46 ` Pedro Alves
  2014-01-06 21:12   ` Tom Tromey
  2014-01-13 14:33 ` Tom Tromey
  5 siblings, 1 reply; 8+ messages in thread
From: Pedro Alves @ 2014-01-06 18:46 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 01/06/2014 05:32 PM, Tom Tromey wrote:
> Right now, gdb defines some allocation macros in defs.h, specifically
> XZALLOC, XMALLOC, and XCALLOC.  libiberty also defines similar
> allocation macros, and gdb uses both variants.
> 
> I think it's somewhat nicer if gdb uses just a single set of wrapper
> macros, and so this patch series replaces all the uses of the gdb
> macros with the corresponding macros from libiberty.
> 
> Let me know what you think.
> 
> Tested by rebuilding on x86-64 Fedora 18 

I assume an --enable-targets=all build.

and doing a cross build to
> mingw.  It's possible therefore that there are some buglets remaining.

Looks fine to me.

-- 
Pedro Alves

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/3] remove overlapping allocation macros
  2014-01-06 18:46 ` Pedro Alves
@ 2014-01-06 21:12   ` Tom Tromey
  0 siblings, 0 replies; 8+ messages in thread
From: Tom Tromey @ 2014-01-06 21:12 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:

>> Tested by rebuilding on x86-64 Fedora 18 

Pedro> I assume an --enable-targets=all build.

Yeah.  Aside from specific cases that's my default build.

Tom

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/3] remove overlapping allocation macros
  2014-01-06 17:32 [PATCH 0/3] remove overlapping allocation macros Tom Tromey
                   ` (4 preceding siblings ...)
  2014-01-06 18:46 ` Pedro Alves
@ 2014-01-13 14:33 ` Tom Tromey
  5 siblings, 0 replies; 8+ messages in thread
From: Tom Tromey @ 2014-01-13 14:33 UTC (permalink / raw)
  To: gdb-patches

>>>>> "Tom" == Tom Tromey <tromey@redhat.com> writes:

Tom> Right now, gdb defines some allocation macros in defs.h, specifically
Tom> XZALLOC, XMALLOC, and XCALLOC.  libiberty also defines similar
Tom> allocation macros, and gdb uses both variants.

Tom> I think it's somewhat nicer if gdb uses just a single set of wrapper
Tom> macros, and so this patch series replaces all the uses of the gdb
Tom> macros with the corresponding macros from libiberty.

I'm checking this in now.

Tom

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-01-13 14:33 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-06 17:32 [PATCH 0/3] remove overlapping allocation macros Tom Tromey
2014-01-06 17:32 ` [PATCH 2/3] replace XMALLOC with XNEW Tom Tromey
2014-01-06 17:32 ` [PATCH 3/3] replace XCALLOC with XCNEWVEC or XCNEW Tom Tromey
2014-01-06 17:32 ` [PATCH 1/3] replace XZALLOC with XCNEW Tom Tromey
2014-01-06 18:14 ` [PATCH 0/3] remove overlapping allocation macros Doug Evans
2014-01-06 18:46 ` Pedro Alves
2014-01-06 21:12   ` Tom Tromey
2014-01-13 14:33 ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).