aboutsummaryrefslogtreecommitdiff
path: root/bfd/hash.c
diff options
context:
space:
mode:
Diffstat (limited to 'bfd/hash.c')
-rw-r--r--bfd/hash.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/bfd/hash.c b/bfd/hash.c
index bccc97d..987c259 100644
--- a/bfd/hash.c
+++ b/bfd/hash.c
@@ -1,22 +1,22 @@
/* hash.c -- hash table routines for BFD
- Copyright 1993 Free Software Foundation, Inc.
+ Copyright (C) 1993, 94 Free Software Foundation, Inc.
Written by Steve Chamberlain <sac@cygnus.com>
-This file is part of GLD, the Gnu Linker.
+This file is part of BFD, the Binary File Descriptor library.
-GLD is free software; you can redistribute it and/or modify
+This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
-GLD is distributed in the hope that it will be useful,
+This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
-along with GLD; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "bfd.h"
#include "sysdep.h"
@@ -290,7 +290,7 @@ SUBSUBSECTION
*/
/* Obstack allocation and deallocation routines. */
-#define obstack_chunk_alloc xmalloc
+#define obstack_chunk_alloc malloc
#define obstack_chunk_free free
/* The default number of entries to use when creating a hash table. */
@@ -309,9 +309,18 @@ bfd_hash_table_init_n (table, newfunc, size)
unsigned int alloc;
alloc = size * sizeof (struct bfd_hash_entry *);
- obstack_begin (&table->memory, alloc);
+ if (!obstack_begin (&table->memory, alloc))
+ {
+ bfd_error = no_memory;
+ return false;
+ }
table->table = ((struct bfd_hash_entry **)
obstack_alloc (&table->memory, alloc));
+ if (!table->table)
+ {
+ bfd_error = no_memory;
+ return false;
+ }
memset ((PTR) table->table, 0, alloc);
table->size = size;
table->newfunc = newfunc;
@@ -388,6 +397,11 @@ bfd_hash_lookup (table, string, create, copy)
char *new;
new = (char *) obstack_alloc (&table->memory, len + 1);
+ if (!new)
+ {
+ bfd_error = no_memory;
+ return (struct bfd_hash_entry *) NULL;
+ }
strcpy (new, string);
string = new;
}