This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

bfd_alloc+memset -> bfd_zalloc


On Sat, Jun 08, 2002 at 12:26:01AM +0930, Alan Modra wrote:
> Also gets rid of a few memset calls.  More to follow in the next patch.

bfd/ChangeLog
	* aoutx.h (NAME(aout,slurp_symbol_table)): Use bfd_zmalloc.
	(NAME(aout,slurp_reloc_table)): Likewise.
	* coff-mips.c (mips_relax_section): Use bfd_zalloc.
	* coff-rs6000.c (xcoff_write_armap_big): Use bfd_zmalloc.
	(xcoff_write_archive_contents_big): Likewise.
	(xcoff_generate_rtinit): Likewise.
	(xcoff_generate_rtinit): Likewise, and check error return.
	* coff64-rs6000.c (xcoff64_generate_rtinit): Likewise.
	* coffgen.c (coff_section_symbol): Use bfd_zalloc.
	(coff_get_normalized_symtab): Likewise.
	(coff_make_empty_symbol): Likewise.
	(bfd_coff_set_symbol_class): Likewise.
	* cofflink.c (coff_link_add_symbols): Likewise.
	* ecoff.c (_bfd_ecoff_make_empty_symbol): Likewise.
	* ecofflink.c (ecoff_write_shuffle): Use bfd_zmalloc.
	(bfd_ecoff_write_accumulated_debug): Likewise.
	* elf64-alpha.c (get_got_entry): Use bfd_zalloc.
	* i386linux.c (bfd_i386linux_size_dynamic_sections): Likewise.
	* i386lynx.c (NAME(lynx,slurp_reloc_table)): Use bfd_zmalloc.
	* ieee.c (do_with_relocs): Use bfd_zalloc.
	* m68klinux.c (bfd_m68klinux_size_dynamic_sections): Likewise.
	* pdp11.c (NAME(aout,slurp_symbol_table)): Use bfd_zmalloc.
	(NAME(aout,slurp_reloc_table)): Likewise.
	(NAME(aout,squirt_out_relocs)): Don't memset when zalloc'd.
	* reloc16.c (bfd_coff_reloc16_relax_section): Use bfd_zmalloc.
	* som.c (som_build_and_write_symbol_table): Likewise.
	(som_slurp_string_table): Likewise.
	(som_slurp_symbol_table): Likewise.
	(som_bfd_ar_write_symbol_stuff): Likewise.
	* sparclinux.c (bfd_sparclinux_size_dynamic_sections): Use bfd_zalloc.
	* sunos.c (bfd_sunos_size_dynamic_sections): Likewise.
	* tekhex.c (find_chunk): Likewise.  Get rid of unused "sname".
	* vms-gsd.c (_bfd_vms_slurp_gsd): Use bfd_zmalloc.
	* xcofflink.c (xcoff_link_add_symbols): Use bfd_zalloc/bfd_zmalloc.

Index: bfd/aoutx.h
===================================================================
RCS file: /cvs/src/src/bfd/aoutx.h,v
retrieving revision 1.28
diff -u -p -r1.28 aoutx.h
--- bfd/aoutx.h	28 Mar 2002 03:27:42 -0000	1.28
+++ bfd/aoutx.h	7 Jun 2002 12:46:09 -0000
@@ -1837,11 +1837,9 @@ NAME(aout,slurp_symbol_table) (abfd)
 
   cached_size = obj_aout_external_sym_count (abfd);
   cached_size *= sizeof (aout_symbol_type);
-  cached = (aout_symbol_type *) bfd_malloc (cached_size);
+  cached = (aout_symbol_type *) bfd_zmalloc (cached_size);
   if (cached == NULL && cached_size != 0)
     return false;
-  if (cached_size != 0)
-    memset (cached, 0, (size_t) cached_size);
 
   /* Convert from external symbol information to internal.  */
   if (! (NAME(aout,translate_symbol_table)
@@ -2411,10 +2409,9 @@ NAME(aout,slurp_reloc_table) (abfd, asec
   count = reloc_size / each_size;
 
   amt = count * sizeof (arelent);
-  reloc_cache = (arelent *) bfd_malloc (amt);
+  reloc_cache = (arelent *) bfd_zmalloc (amt);
   if (reloc_cache == NULL && count != 0)
     return false;
-  memset (reloc_cache, 0, (size_t) amt);
 
   relocs = bfd_malloc (reloc_size);
   if (relocs == NULL && reloc_size != 0)
Index: bfd/coff-mips.c
===================================================================
RCS file: /cvs/src/src/bfd/coff-mips.c,v
retrieving revision 1.17
diff -u -p -r1.17 coff-mips.c
--- bfd/coff-mips.c	5 Jun 2002 04:22:27 -0000	1.17
+++ bfd/coff-mips.c	7 Jun 2002 12:46:11 -0000
@@ -2116,10 +2116,9 @@ mips_relax_section (abfd, sec, info, aga
 	  bfd_size_type size;
 
 	  size = (bfd_size_type) sec->reloc_count * sizeof (long);
-	  offsets = (long *) bfd_alloc (abfd, size);
+	  offsets = (long *) bfd_zalloc (abfd, size);
 	  if (offsets == (long *) NULL)
 	    goto error_return;
-	  memset (offsets, 0, (size_t) size);
 	  section_tdata->offsets = offsets;
 	}
 
Index: bfd/coff-rs6000.c
===================================================================
RCS file: /cvs/src/src/bfd/coff-rs6000.c,v
retrieving revision 1.42
diff -u -p -r1.42 coff-rs6000.c
--- bfd/coff-rs6000.c	5 Jun 2002 03:43:09 -0000	1.42
+++ bfd/coff-rs6000.c	7 Jun 2002 12:46:16 -0000
@@ -1839,10 +1839,9 @@ xcoff_write_armap_big (abfd, elength, ma
 	+ str_32 + (str_32 & 1);
 
       symbol_table = NULL;
-      symbol_table = (bfd_byte *) bfd_malloc (symbol_table_size);
+      symbol_table = (bfd_byte *) bfd_zmalloc (symbol_table_size);
       if (symbol_table == NULL)
 	return false;
-      memset (symbol_table, 0, symbol_table_size);
 
       hdr = (struct xcoff_ar_hdr_big *) symbol_table;
 	
@@ -1943,10 +1942,9 @@ xcoff_write_armap_big (abfd, elength, ma
 	+ str_64 + (str_64 & 1);
 
       symbol_table = NULL;
-      symbol_table = (bfd_byte *) bfd_malloc (symbol_table_size);
+      symbol_table = (bfd_byte *) bfd_zmalloc (symbol_table_size);
       if (symbol_table == NULL)
 	return false;
-      memset (symbol_table, 0, symbol_table_size);
 
       hdr = (struct xcoff_ar_hdr_big *) symbol_table;
 
@@ -2457,10 +2455,9 @@ xcoff_write_archive_contents_big (abfd)
 
   member_table_size += member_table_size & 1;
   member_table = NULL;
-  member_table = (bfd_byte *) bfd_malloc (member_table_size);
+  member_table = (bfd_byte *) bfd_zmalloc (member_table_size);
   if (member_table == NULL)
     return false;
-  memset (member_table, 0, member_table_size);
 
   hdr = (struct xcoff_ar_hdr_big *) member_table;
 
@@ -3719,11 +3716,9 @@ xcoff_generate_rtinit  (abfd, init, fini
   data_buffer_size = 0x0040 + initsz + finisz;
   data_buffer_size += (data_buffer_size & 7) ? 8 - (data_buffer_size & 7) : 0;
   data_buffer = NULL;
-  data_buffer = (bfd_byte *) bfd_malloc (data_buffer_size);
+  data_buffer = (bfd_byte *) bfd_zmalloc (data_buffer_size);
   if (data_buffer == NULL)
     return false;
-  
-  memset (data_buffer, 0, data_buffer_size);
 
   if (initsz) 
     {
@@ -3757,8 +3752,10 @@ xcoff_generate_rtinit  (abfd, init, fini
   if (string_table_size)
     {
       string_table_size += 4;
-      string_table = (bfd_byte *)bfd_malloc (string_table_size);
-      memset (string_table, 0, string_table_size);
+      string_table = (bfd_byte *) bfd_zmalloc (string_table_size);
+      if (string_table_size == NULL)
+	return false;
+
       val = string_table_size;
       bfd_h_put_32 (abfd, val, &string_table[0]);
       st_tmp = string_table + 4;
Index: bfd/coff64-rs6000.c
===================================================================
RCS file: /cvs/src/src/bfd/coff64-rs6000.c,v
retrieving revision 1.31
diff -u -p -r1.31 coff64-rs6000.c
--- bfd/coff64-rs6000.c	5 Jun 2002 03:43:09 -0000	1.31
+++ bfd/coff64-rs6000.c	7 Jun 2002 12:46:19 -0000
@@ -2264,12 +2264,10 @@ xcoff64_generate_rtinit (abfd, init, fin
   data_buffer_size = 0x0058 + initsz + finisz;
   data_buffer_size += (data_buffer_size & 7) ? 8 - (data_buffer_size & 7) : 0;
   data_buffer = NULL;
-  data_buffer = (bfd_byte *)bfd_malloc (data_buffer_size);
+  data_buffer = (bfd_byte *) bfd_zmalloc (data_buffer_size);
   if (data_buffer == NULL)
     return false;
 
-  memset (data_buffer, 0, data_buffer_size);
-
   if (initsz)
     {
       val = 0x18;
@@ -2302,8 +2300,10 @@ xcoff64_generate_rtinit (abfd, init, fin
   if (true == rtld)
     string_table_size += strlen (rtld_name) + 1;
 
-  string_table = (bfd_byte *)bfd_malloc (string_table_size);
-  memset (string_table, 0, string_table_size);
+  string_table = (bfd_byte *) bfd_zmalloc (string_table_size);
+  if (string_table == NULL)
+    return false;
+
   val = string_table_size;
   bfd_put_32 (abfd, val, &string_table[0]);
   st_tmp = string_table + 4;
Index: bfd/coffgen.c
===================================================================
RCS file: /cvs/src/src/bfd/coffgen.c,v
retrieving revision 1.31
diff -u -p -r1.31 coffgen.c
--- bfd/coffgen.c	25 Jan 2002 15:13:52 -0000	1.31
+++ bfd/coffgen.c	7 Jun 2002 12:46:21 -0000
@@ -1,6 +1,6 @@
 /* Support for the generic parts of COFF, for BFD.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001
+   2000, 2001, 2002
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
@@ -1438,13 +1438,13 @@ coff_section_symbol (abfd, name)
 	  combined_entry_type e[10];
 	};
       struct foo *f;
-      f = (struct foo *) bfd_alloc (abfd, (bfd_size_type) sizeof (*f));
+
+      f = (struct foo *) bfd_zalloc (abfd, (bfd_size_type) sizeof (*f));
       if (!f)
 	{
 	  bfd_set_error (bfd_error_no_error);
 	  return NULL;
 	}
-      memset ((char *) f, 0, sizeof (*f));
       coff_symbol_from (abfd, sym)->native = csym = f->e;
     }
   csym[0].u.syment.n_sclass = C_STAT;
@@ -1835,10 +1835,9 @@ coff_get_normalized_symtab (abfd)
 		if (internal_ptr->u.syment._n._n_name[i] == '\0')
 		  break;
 
-	      newstring = (PTR) bfd_alloc (abfd, (bfd_size_type) (i + 1));
+	      newstring = (PTR) bfd_zalloc (abfd, (bfd_size_type) (i + 1));
 	      if (newstring == NULL)
 		return (NULL);
-	      memset (newstring, 0, i + 1);
 	      strncpy (newstring, internal_ptr->u.syment._n._n_name, i);
 	      internal_ptr->u.syment._n._n_n._n_offset = (long int) newstring;
 	      internal_ptr->u.syment._n._n_n._n_zeroes = 0;
@@ -1897,10 +1896,9 @@ coff_make_empty_symbol (abfd)
      bfd *abfd;
 {
   bfd_size_type amt = sizeof (coff_symbol_type);
-  coff_symbol_type *new = (coff_symbol_type *) bfd_alloc (abfd, amt);
+  coff_symbol_type *new = (coff_symbol_type *) bfd_zalloc (abfd, amt);
   if (new == NULL)
     return (NULL);
-  memset (new, 0, sizeof *new);
   new->symbol.section = 0;
   new->native = 0;
   new->lineno = (alent *) NULL;
@@ -2453,11 +2451,9 @@ bfd_coff_set_symbol_class (abfd, symbol,
       combined_entry_type * native;
       bfd_size_type amt = sizeof (* native);
 
-      native = (combined_entry_type *) bfd_alloc (abfd, amt);
+      native = (combined_entry_type *) bfd_zalloc (abfd, amt);
       if (native == NULL)
 	return false;
-
-      memset (native, 0, sizeof (* native));
 
       native->u.syment.n_type   = T_NULL;
       native->u.syment.n_sclass = class;
Index: bfd/cofflink.c
===================================================================
RCS file: /cvs/src/src/bfd/cofflink.c,v
retrieving revision 1.32
diff -u -p -r1.32 cofflink.c
--- bfd/cofflink.c	4 Apr 2002 19:53:35 -0000	1.32
+++ bfd/cofflink.c	7 Jun 2002 12:46:24 -0000
@@ -342,12 +342,10 @@ coff_link_add_symbols (abfd, info)
   /* We keep a list of the linker hash table entries that correspond
      to particular symbols.  */
   amt = symcount * sizeof (struct coff_link_hash_entry *);
-  sym_hash = (struct coff_link_hash_entry **) bfd_alloc (abfd, amt);
+  sym_hash = (struct coff_link_hash_entry **) bfd_zalloc (abfd, amt);
   if (sym_hash == NULL && symcount != 0)
     goto error_return;
   obj_coff_sym_hashes (abfd) = sym_hash;
-  memset (sym_hash, 0,
-	  (size_t) symcount * sizeof (struct coff_link_hash_entry *));
 
   symesz = bfd_coff_symesz (abfd);
   BFD_ASSERT (symesz == bfd_coff_auxesz (abfd));
Index: bfd/ecoff.c
===================================================================
RCS file: /cvs/src/src/bfd/ecoff.c,v
retrieving revision 1.15
diff -u -p -r1.15 ecoff.c
--- bfd/ecoff.c	4 Apr 2002 19:53:35 -0000	1.15
+++ bfd/ecoff.c	7 Jun 2002 12:46:32 -0000
@@ -661,10 +661,9 @@ _bfd_ecoff_make_empty_symbol (abfd)
   ecoff_symbol_type *new;
   bfd_size_type amt = sizeof (ecoff_symbol_type);
 
-  new = (ecoff_symbol_type *) bfd_alloc (abfd, amt);
+  new = (ecoff_symbol_type *) bfd_zalloc (abfd, amt);
   if (new == (ecoff_symbol_type *) NULL)
     return (asymbol *) NULL;
-  memset ((PTR) new, 0, sizeof *new);
   new->symbol.section = (asection *) NULL;
   new->fdr = (FDR *) NULL;
   new->local = false;
Index: bfd/ecofflink.c
===================================================================
RCS file: /cvs/src/src/bfd/ecofflink.c,v
retrieving revision 1.6
diff -u -p -r1.6 ecofflink.c
--- bfd/ecofflink.c	20 Sep 2001 23:30:34 -0000	1.6
+++ bfd/ecofflink.c	7 Jun 2002 12:46:35 -0000
@@ -1,5 +1,5 @@
 /* Routines to link ECOFF debugging information.
-   Copyright 1993, 1994, 1995, 1996, 1997, 2000, 2001
+   Copyright 1993, 1994, 1995, 1996, 1997, 2000, 2001, 2002
    Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Cygnus Support, <ian@cygnus.com>.
 
@@ -1650,11 +1650,10 @@ ecoff_write_shuffle (abfd, swap, shuffle
       bfd_byte *s;
 
       i = swap->debug_align - (total & (swap->debug_align - 1));
-      s = (bfd_byte *) bfd_malloc ((bfd_size_type) i);
+      s = (bfd_byte *) bfd_zmalloc ((bfd_size_type) i);
       if (s == NULL && i != 0)
 	return false;
 
-      memset ((PTR) s, 0, i);
       if (bfd_bwrite ((PTR) s, (bfd_size_type) i, abfd) != i)
 	{
 	  free (s);
@@ -1736,10 +1735,10 @@ bfd_ecoff_write_accumulated_debug (handl
 	  bfd_byte *s;
 
 	  i = swap->debug_align - (total & (swap->debug_align - 1));
-	  s = (bfd_byte *) bfd_malloc ((bfd_size_type) i);
+	  s = (bfd_byte *) bfd_zmalloc ((bfd_size_type) i);
 	  if (s == NULL && i != 0)
 	    goto error_return;
-	  memset ((PTR) s, 0, i);
+
 	  if (bfd_bwrite ((PTR) s, (bfd_size_type) i, abfd) != i)
 	    {
 	      free (s);
@@ -1761,10 +1760,10 @@ bfd_ecoff_write_accumulated_debug (handl
 
       i = (swap->debug_align
 	   - (debug->symbolic_header.issExtMax & (swap->debug_align - 1)));
-      s = (bfd_byte *) bfd_malloc ((bfd_size_type) i);
+      s = (bfd_byte *) bfd_zmalloc ((bfd_size_type) i);
       if (s == NULL && i != 0)
 	goto error_return;
-      memset ((PTR) s, 0, i);
+
       if (bfd_bwrite ((PTR) s, (bfd_size_type) i, abfd) != i)
 	{
 	  free (s);
Index: bfd/elf64-alpha.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-alpha.c,v
retrieving revision 1.74
diff -u -p -r1.74 elf64-alpha.c
--- bfd/elf64-alpha.c	6 Jun 2002 00:29:21 -0000	1.74
+++ bfd/elf64-alpha.c	7 Jun 2002 12:46:47 -0000
@@ -2974,11 +2974,10 @@ get_got_entry (abfd, h, r_type, r_symndx
 	  size *= sizeof (struct alpha_elf_got_entry *);
 
 	  local_got_entries
-	    = (struct alpha_elf_got_entry **) bfd_alloc (abfd, size);
+	    = (struct alpha_elf_got_entry **) bfd_zalloc (abfd, size);
 	  if (!local_got_entries)
 	    return NULL;
 
-	  memset (local_got_entries, 0, (size_t) size);
 	  alpha_elf_tdata (abfd)->local_got_entries = local_got_entries;
 	}
 
Index: bfd/i386linux.c
===================================================================
RCS file: /cvs/src/src/bfd/i386linux.c,v
retrieving revision 1.6
diff -u -p -r1.6 i386linux.c
--- bfd/i386linux.c	28 Mar 2002 03:27:45 -0000	1.6
+++ bfd/i386linux.c	7 Jun 2002 12:46:55 -0000
@@ -597,10 +597,9 @@ bfd_i386linux_size_dynamic_sections (out
     {
       s->_raw_size = linux_hash_table (info)->fixup_count + 1;
       s->_raw_size *= 8;
-      s->contents = (bfd_byte *) bfd_alloc (output_bfd, s->_raw_size);
+      s->contents = (bfd_byte *) bfd_zalloc (output_bfd, s->_raw_size);
       if (s->contents == NULL)
 	return false;
-      memset (s->contents, 0, (size_t) s->_raw_size);
     }
 
   return true;
Index: bfd/i386lynx.c
===================================================================
RCS file: /cvs/src/src/bfd/i386lynx.c,v
retrieving revision 1.6
diff -u -p -r1.6 i386lynx.c
--- bfd/i386lynx.c	2 Oct 2001 05:58:41 -0000	1.6
+++ bfd/i386lynx.c	7 Jun 2002 12:46:55 -0000
@@ -1,5 +1,5 @@
 /* BFD back-end for i386 a.out binaries under LynxOS.
-   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 2001
+   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 2001, 2002
    Free Software Foundation, Inc.
 
 This file is part of BFD, the Binary File Descriptor library.
@@ -429,10 +429,9 @@ doit:
   count = reloc_size / each_size;
 
 
-  reloc_cache = (arelent *) bfd_malloc (count * sizeof (arelent));
+  reloc_cache = (arelent *) bfd_zmalloc (count * sizeof (arelent));
   if (!reloc_cache && count != 0)
     return false;
-  memset (reloc_cache, 0, (size_t) count * sizeof (arelent));
 
   relocs = (PTR) bfd_alloc (abfd, reloc_size);
   if (!relocs && reloc_size != 0)
Index: bfd/ieee.c
===================================================================
RCS file: /cvs/src/src/bfd/ieee.c,v
retrieving revision 1.25
diff -u -p -r1.25 ieee.c
--- bfd/ieee.c	5 Jun 2002 03:43:10 -0000	1.25
+++ bfd/ieee.c	7 Jun 2002 12:46:58 -0000
@@ -2398,10 +2398,9 @@ do_with_relocs (abfd, s)
       if ((PTR) stream == (PTR) NULL)
 	{
 	  /* Outputting a section without data, fill it up */
-	  stream = (unsigned char *) (bfd_alloc (abfd, s->_raw_size));
+	  stream = (unsigned char *) bfd_zalloc (abfd, s->_raw_size);
 	  if (!stream)
 	    return false;
-	  memset ((PTR) stream, 0, (size_t) s->_raw_size);
 	}
       while (current_byte_index < s->_raw_size)
 	{
Index: bfd/m68klinux.c
===================================================================
RCS file: /cvs/src/src/bfd/m68klinux.c,v
retrieving revision 1.9
diff -u -p -r1.9 m68klinux.c
--- bfd/m68klinux.c	4 Apr 2002 19:53:37 -0000	1.9
+++ bfd/m68klinux.c	7 Jun 2002 12:46:58 -0000
@@ -601,13 +601,12 @@ bfd_m68klinux_size_dynamic_sections (out
     {
       s->_raw_size = linux_hash_table (info)->fixup_count + 1;
       s->_raw_size *= 8;
-      s->contents = (bfd_byte *) bfd_alloc (output_bfd, s->_raw_size);
+      s->contents = (bfd_byte *) bfd_zalloc (output_bfd, s->_raw_size);
       if (s->contents == NULL)
 	{
 	  bfd_set_error (bfd_error_no_memory);
 	  return false;
 	}
-      memset (s->contents, 0, (size_t) s->_raw_size);
     }
 
   return true;
Index: bfd/pdp11.c
===================================================================
RCS file: /cvs/src/src/bfd/pdp11.c,v
retrieving revision 1.12
diff -u -p -r1.12 pdp11.c
--- bfd/pdp11.c	28 Mar 2002 03:27:45 -0000	1.12
+++ bfd/pdp11.c	7 Jun 2002 12:47:03 -0000
@@ -1841,11 +1841,9 @@ NAME(aout,slurp_symbol_table) (abfd)
 
   cached_size = obj_aout_external_sym_count (abfd);
   cached_size *= sizeof (aout_symbol_type);
-  cached = (aout_symbol_type *) bfd_malloc (cached_size);
+  cached = (aout_symbol_type *) bfd_zmalloc (cached_size);
   if (cached == NULL && cached_size != 0)
     return false;
-  if (cached_size != 0)
-    memset (cached, 0, (size_t) cached_size);
 
   /* Convert from external symbol information to internal.  */
   if (! (NAME(aout,translate_symbol_table)
@@ -2255,10 +2253,9 @@ NAME(aout,slurp_reloc_table) (abfd, asec
     count = real_count;
   }
 
-  reloc_cache = (arelent *) bfd_malloc (count * sizeof (arelent));
+  reloc_cache = (arelent *) bfd_zmalloc (count * sizeof (arelent));
   if (reloc_cache == NULL && count != 0)
     return false;
-  memset (reloc_cache, 0, (size_t) count * sizeof (arelent));
 
   cache_ptr = reloc_cache;
 
@@ -2318,8 +2315,6 @@ NAME(aout,squirt_out_relocs) (abfd, sect
   native = (unsigned char *) bfd_zalloc (abfd, natsize);
   if (!native)
     return false;
-
-  memset ((PTR)native, 0, (size_t) natsize);
 
   generic = section->orelocation;
   if (generic != NULL)
Index: bfd/reloc16.c
===================================================================
RCS file: /cvs/src/src/bfd/reloc16.c,v
retrieving revision 1.6
diff -u -p -r1.6 reloc16.c
--- bfd/reloc16.c	18 Sep 2001 09:57:26 -0000	1.6
+++ bfd/reloc16.c	7 Jun 2002 12:47:03 -0000
@@ -196,8 +196,7 @@ bfd_coff_reloc16_relax_section (abfd, in
          The last element is used as an accumlator of shrinks.  */
       amt = reloc_count + 1;
       amt *= sizeof (unsigned);
-      shrinks = (unsigned *) bfd_malloc (amt);
-      memset (shrinks, 0, (size_t) amt);
+      shrinks = (unsigned *) bfd_zmalloc (amt);
 
       /* Loop until nothing changes in this section.  */
       do {
Index: bfd/som.c
===================================================================
RCS file: /cvs/src/src/bfd/som.c,v
retrieving revision 1.31
diff -u -p -r1.31 som.c
--- bfd/som.c	5 Jun 2002 03:43:11 -0000	1.31
+++ bfd/som.c	7 Jun 2002 12:47:07 -0000
@@ -4141,10 +4141,9 @@ som_build_and_write_symbol_table (abfd)
      to hold the symbol table as we build it.  */
   symtab_size = num_syms;
   symtab_size *= sizeof (struct symbol_dictionary_record);
-  som_symtab = (struct symbol_dictionary_record *) bfd_malloc (symtab_size);
+  som_symtab = (struct symbol_dictionary_record *) bfd_zmalloc (symtab_size);
   if (som_symtab == NULL && symtab_size != 0)
     goto error_return;
-  memset (som_symtab, 0, (size_t) symtab_size);
 
   /* Walk over each symbol.  */
   for (i = 0; i < num_syms; i++)
@@ -4230,10 +4229,9 @@ som_slurp_string_table (abfd)
 
   /* Allocate and read in the string table.  */
   amt = obj_som_stringtab_size (abfd);
-  stringtab = bfd_malloc (amt);
+  stringtab = bfd_zmalloc (amt);
   if (stringtab == NULL)
     return false;
-  memset (stringtab, 0, obj_som_stringtab_size (abfd));
 
   if (bfd_seek (abfd, obj_som_str_filepos (abfd), SEEK_SET) != 0)
     return false;
@@ -4336,10 +4334,9 @@ som_slurp_symbol_table (abfd)
 
   amt = symbol_count;
   amt *= sizeof (som_symbol_type);
-  symbase = (som_symbol_type *) bfd_malloc (amt);
+  symbase = (som_symbol_type *) bfd_zmalloc (amt);
   if (symbase == NULL)
     goto error_return;
-  memset (symbase, 0, symbol_count * sizeof (som_symbol_type));
 
   /* Read in the external SOM representation.  */
   amt = symbol_count;
@@ -5899,31 +5896,25 @@ som_bfd_ar_write_symbol_stuff (abfd, nsy
 
   amt = lst.hash_size;
   amt *= sizeof (unsigned int);
-  hash_table = (unsigned int *) bfd_malloc (amt);
+  hash_table = (unsigned int *) bfd_zmalloc (amt);
   if (hash_table == NULL && lst.hash_size != 0)
     goto error_return;
 
   amt = lst.module_count;
   amt *= sizeof (struct som_entry);
-  som_dict = (struct som_entry *) bfd_malloc (amt);
+  som_dict = (struct som_entry *) bfd_zmalloc (amt);
   if (som_dict == NULL && lst.module_count != 0)
     goto error_return;
 
   amt = lst.hash_size;
   amt *= sizeof (struct lst_symbol_record *);
-  last_hash_entry = ((struct lst_symbol_record **) bfd_malloc (amt));
+  last_hash_entry = ((struct lst_symbol_record **) bfd_zmalloc (amt));
   if (last_hash_entry == NULL && lst.hash_size != 0)
     goto error_return;
 
   /* Lots of fields are file positions relative to the start
      of the lst record.  So save its location.  */
   lst_filepos = bfd_tell (abfd) - sizeof (struct lst_header);
-
-  /* Some initialization.  */
-  memset (hash_table, 0, 4 * lst.hash_size);
-  memset (som_dict, 0, lst.module_count * sizeof (struct som_entry));
-  memset (last_hash_entry, 0,
-	  lst.hash_size * sizeof (struct lst_symbol_record *));
 
   /* Symbols have som_index fields, so we have to keep track of the
      index of each SOM in the archive.
Index: bfd/sparclinux.c
===================================================================
RCS file: /cvs/src/src/bfd/sparclinux.c,v
retrieving revision 1.8
diff -u -p -r1.8 sparclinux.c
--- bfd/sparclinux.c	4 Apr 2002 19:53:38 -0000	1.8
+++ bfd/sparclinux.c	7 Jun 2002 12:47:09 -0000
@@ -599,10 +599,9 @@ bfd_sparclinux_size_dynamic_sections (ou
     {
       s->_raw_size = linux_hash_table (info)->fixup_count + 1;
       s->_raw_size *= 8;
-      s->contents = (bfd_byte *) bfd_alloc (output_bfd, s->_raw_size);
+      s->contents = (bfd_byte *) bfd_zalloc (output_bfd, s->_raw_size);
       if (s->contents == NULL)
        return false;
-      memset (s->contents, 0, (size_t) s->_raw_size);
     }
 
   return true;
Index: bfd/sunos.c
===================================================================
RCS file: /cvs/src/src/bfd/sunos.c,v
retrieving revision 1.9
diff -u -p -r1.9 sunos.c
--- bfd/sunos.c	4 Apr 2002 19:53:38 -0000	1.9
+++ bfd/sunos.c	7 Jun 2002 12:47:10 -0000
@@ -1434,10 +1434,9 @@ bfd_sunos_size_dynamic_sections (output_
       s = bfd_get_section_by_name (dynobj, ".hash");
       BFD_ASSERT (s != NULL);
       hashalloc = (dynsymcount + bucketcount - 1) * HASH_ENTRY_SIZE;
-      s->contents = (bfd_byte *) bfd_alloc (dynobj, hashalloc);
+      s->contents = (bfd_byte *) bfd_zalloc (dynobj, hashalloc);
       if (s->contents == NULL && dynsymcount > 0)
 	return false;
-      memset (s->contents, 0, (size_t) hashalloc);
       for (i = 0; i < bucketcount; i++)
 	PUT_WORD (output_bfd, (bfd_vma) -1, s->contents + i * HASH_ENTRY_SIZE);
       s->_raw_size = bucketcount * HASH_ENTRY_SIZE;
Index: bfd/tekhex.c
===================================================================
RCS file: /cvs/src/src/bfd/tekhex.c,v
retrieving revision 1.11
diff -u -p -r1.11 tekhex.c
--- bfd/tekhex.c	5 Jun 2002 03:43:11 -0000	1.11
+++ bfd/tekhex.c	7 Jun 2002 12:47:11 -0000
@@ -354,17 +354,13 @@ find_chunk (abfd, vma)
     }
   if (!d)
     {
-      char *sname = bfd_alloc (abfd, (bfd_size_type) 12);
-
       /* No chunk for this address, so make one up */
       d = ((struct data_struct *)
-	   bfd_alloc (abfd, (bfd_size_type) sizeof (struct data_struct)));
+	   bfd_zalloc (abfd, (bfd_size_type) sizeof (struct data_struct)));
 
-      if (!sname || !d)
+      if (!d)
 	return NULL;
 
-      memset (d->chunk_init, 0, CHUNK_MASK + 1);
-      memset (d->chunk_data, 0, CHUNK_MASK + 1);
       d->next = abfd->tdata.tekhex_data->data;
       d->vma = vma;
       abfd->tdata.tekhex_data->data = d;
Index: bfd/vms-gsd.c
===================================================================
RCS file: /cvs/src/src/bfd/vms-gsd.c,v
retrieving revision 1.9
diff -u -p -r1.9 vms-gsd.c
--- bfd/vms-gsd.c	6 Jan 2002 07:30:35 -0000	1.9
+++ bfd/vms-gsd.c	7 Jun 2002 12:47:13 -0000
@@ -426,13 +426,12 @@ _bfd_vms_slurp_gsd (abfd, objtype)
 	      else
 		{
 		  section->contents = ((unsigned char *)
-				       bfd_malloc (section->_raw_size));
+				       bfd_zmalloc (section->_raw_size));
 		  if (section->contents == NULL)
 		    {
 		      bfd_set_error (bfd_error_no_memory);
 		      return -1;
 		    }
-		  memset (section->contents, 0, (size_t) section->_raw_size);
 		}
 	      section->_cooked_size = section->_raw_size;
 #if VMS_DEBUG
@@ -618,10 +617,9 @@ _bfd_vms_slurp_gsd (abfd, objtype)
 	    section->vma = (bfd_vma)base_addr;
 	    base_addr += section->_raw_size;
 	    section->contents = ((unsigned char *)
-				 bfd_malloc (section->_raw_size));
+				 bfd_zmalloc (section->_raw_size));
 	    if (section->contents == NULL)
 	      return -1;
-	    memset (section->contents, 0, (size_t) section->_raw_size);
 	    section->_cooked_size = section->_raw_size;
 #if VMS_DEBUG
 	    vms_debug(4, "egsd psc %d (%s, flags %04x=%s) ",
Index: bfd/xcofflink.c
===================================================================
RCS file: /cvs/src/src/bfd/xcofflink.c,v
retrieving revision 1.25
diff -u -p -r1.25 xcofflink.c
--- bfd/xcofflink.c	30 Apr 2002 04:32:51 -0000	1.25
+++ bfd/xcofflink.c	7 Jun 2002 12:47:18 -0000
@@ -1086,21 +1086,19 @@ xcoff_link_add_symbols (abfd, info)
   /* We keep a list of the linker hash table entries that correspond
      to each external symbol.  */
   amt = symcount * sizeof (struct xcoff_link_hash_entry *);
-  sym_hash = (struct xcoff_link_hash_entry **) bfd_alloc (abfd, amt);
+  sym_hash = (struct xcoff_link_hash_entry **) bfd_zalloc (abfd, amt);
   if (sym_hash == NULL && symcount != 0)
     goto error_return;
   coff_data (abfd)->sym_hashes = (struct coff_link_hash_entry **) sym_hash;
-  memset (sym_hash, 0, (size_t) amt);
 
   /* Because of the weird stuff we are doing with XCOFF csects, we can
      not easily determine which section a symbol is in, so we store
      the information in the tdata for the input file.  */
   amt = symcount * sizeof (asection *);
-  csect_cache = (asection **) bfd_alloc (abfd, amt);
+  csect_cache = (asection **) bfd_zalloc (abfd, amt);
   if (csect_cache == NULL && symcount != 0)
     goto error_return;
   xcoff_data (abfd)->csects = csect_cache;
-  memset (csect_cache, 0, (size_t) amt);
 
   /* While splitting sections into csects, we need to assign the
      relocs correctly.  The relocs and the csects must both be in
@@ -1109,10 +1107,9 @@ xcoff_link_add_symbols (abfd, info)
      into reloc_info using the section target_index.  */
   amt = abfd->section_count + 1;
   amt *= sizeof (struct reloc_info_struct);
-  reloc_info = (struct reloc_info_struct *) bfd_malloc (amt);
+  reloc_info = (struct reloc_info_struct *) bfd_zmalloc (amt);
   if (reloc_info == NULL)
     goto error_return;
-  memset ((PTR) reloc_info, 0, (size_t) amt);
 
   /* Read in the relocs and line numbers for each section.  */
   linesz = bfd_coff_linesz (abfd);
@@ -1129,11 +1126,9 @@ xcoff_link_add_symbols (abfd, info)
 					false, (struct internal_reloc *) NULL);
 	  amt = o->reloc_count;
 	  amt *= sizeof (asection *);
-	  reloc_info[o->target_index].csects = (asection **) bfd_malloc (amt);
+	  reloc_info[o->target_index].csects = (asection **) bfd_zmalloc (amt);
 	  if (reloc_info[o->target_index].csects == NULL)
 	    goto error_return;
-	  memset (reloc_info[o->target_index].csects, 0, (size_t) amt);
-
 	}
 
       if ((info->strip == strip_none || info->strip == strip_some)

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]