This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: PATCH: robustify bfd/linker.c:archive_hash_newfunc
> If you want to rework this function, I think you should rework it to
> look like all the other newfunc functions:
How is this revised patch? I'm sure you will recognise it. ;-)
Ben
2006-10-26 Ben Elliston <bje@au.ibm.com>
Ian Lance Taylor <iant@google.com>
* linker.c (archive_hash_newfunc): Rewrite.
Index: linker.c
===================================================================
RCS file: /cvs/src/src/bfd/linker.c,v
retrieving revision 1.56
diff -u -p -r1.56 linker.c
--- linker.c 23 Oct 2006 02:35:38 -0000 1.56
+++ linker.c 26 Oct 2006 00:23:38 -0000
@@ -874,26 +874,25 @@ archive_hash_newfunc (struct bfd_hash_en
struct bfd_hash_table *table,
const char *string)
{
- struct archive_hash_entry *ret = (struct archive_hash_entry *) entry;
-
- /* Allocate the structure if it has not already been allocated by a
- subclass. */
- if (ret == NULL)
- ret = bfd_hash_allocate (table, sizeof (struct archive_hash_entry));
- if (ret == NULL)
- return NULL;
-
+ if (entry == NULL)
+ {
+ entry = bfd_hash_allocate (table, sizeof (struct archive_hash_entry));
+ if (entry == NULL)
+ return entry;
+ }
+
/* Call the allocation method of the superclass. */
- ret = ((struct archive_hash_entry *)
- bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string));
-
- if (ret)
+ entry = bfd_hash_newfunc (entry, table, string);
+ if (entry)
{
+ struct archive_hash_entry *ret;
+
/* Initialize the local fields. */
+ ret = (struct archive_hash_entry *) entry;
ret->defs = NULL;
}
- return &ret->root;
+ return entry;
}
/* Initialize an archive hash table. */