This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
patch to avoid xmalloc uses for hash tables
- From: Geoffrey Keating <geoffk at romulus dot sfbay dot redhat dot com>
- To: binutils at sources dot redhat dot com
- Cc: dj at redhat dot com, Eric Christopher <echristo at redhat dot com>, Elena Zannoni <ezannoni at redhat dot com>
- Date: Thu, 6 Jun 2002 01:50:50 -0700
- Subject: patch to avoid xmalloc uses for hash tables
I believe there's a policy that xmalloc shouldn't be used in bfd;
but htab_create has always used it. This makes the code I changed
below somewhat odd, since it clearly expects that htab_create can
fail.
Anyway, this fixes it and incidentally allows bfd to build with the
new libiberty.
OK to commit, after a ld testsuite run on powerpc-eabisim succeeds?
--
Geoff Keating <geoffk@redhat.com>
===File ~/patches/ld-htaballoc.patch========================
2002-06-06 Geoffrey Keating <geoffk@redhat.com>
* merge.c (merge_strings): Use htab_create_alloc with calloc, not
htab_alloc.
* elf-strtab.c (_bfd_elf_strtab_finalize): Likewise.
Index: elf-strtab.c
===================================================================
RCS file: /cvs/src/src/bfd/elf-strtab.c,v
retrieving revision 1.3
diff -p -u -p -r1.3 elf-strtab.c
--- elf-strtab.c 18 Dec 2001 11:47:59 -0000 1.3
+++ elf-strtab.c 6 Jun 2002 08:50:31 -0000
@@ -351,7 +351,7 @@ _bfd_elf_strtab_finalize (tab)
qsort (array, size, sizeof (struct elf_strtab_hash_entry *), cmplengthentry);
- last4tab = htab_create (size * 4, NULL, last4_eq, NULL);
+ last4tab = htab_create_alloc (size * 4, NULL, last4_eq, NULL, calloc, free);
if (last4tab == NULL)
goto alloc_failure;
Index: merge.c
===================================================================
RCS file: /cvs/src/src/bfd/merge.c,v
retrieving revision 1.9
diff -p -u -p -r1.9 merge.c
--- merge.c 5 Mar 2002 12:19:08 -0000 1.9
+++ merge.c 6 Jun 2002 08:50:31 -0000
@@ -650,8 +650,10 @@ merge_strings (sinfo)
qsort (array, (size_t) sinfo->htab->size,
sizeof (struct sec_merge_hash_entry *), cmplengthentry);
- last4tab = htab_create ((size_t) sinfo->htab->size * 4, NULL, last4_eq, NULL);
- lasttab = htab_create ((size_t) sinfo->htab->size * 4, NULL, last_eq, NULL);
+ last4tab = htab_create_alloc ((size_t) sinfo->htab->size * 4,
+ NULL, last4_eq, NULL, calloc, free);
+ lasttab = htab_create_alloc ((size_t) sinfo->htab->size * 4,
+ NULL, last_eq, NULL, calloc, free);
if (lasttab == NULL || last4tab == NULL)
goto alloc_failure;
============================================================