~ubuntu-branches/debian/squeeze/binutils/squeeze

« back to all changes in this revision

Viewing changes to bfd/hash.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2009-09-10 17:05:30 UTC
  • mfrom: (1.4.5 upstream) (6.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20090910170530-wa6gpju9pq5c56on
Tags: 2.19.91.20090910-1
* Snapshot, taken from the 2.20 release branch 20090910, corresponding
  to the 2.19.90 upstream snapshot.
* Fix Thumb-2 shared libraries (Daniel Jacobowitz), patch taken
  from the trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* hash.c -- hash table routines for BFD
2
2
   Copyright 1993, 1994, 1995, 1997, 1999, 2001, 2002, 2003, 2004, 2005,
3
 
   2006, 2007 Free Software Foundation, Inc.
 
3
   2006, 2007, 2009 Free Software Foundation, Inc.
4
4
   Written by Steve Chamberlain <sac@cygnus.com>
5
5
 
6
6
   This file is part of BFD, the Binary File Descriptor library.
374
374
      bfd_set_error (bfd_error_no_memory);
375
375
      return FALSE;
376
376
    }
377
 
  table->table = objalloc_alloc ((struct objalloc *) table->memory, alloc);
 
377
  table->table = (struct bfd_hash_entry **)
 
378
      objalloc_alloc ((struct objalloc *) table->memory, alloc);
378
379
  if (table->table == NULL)
379
380
    {
380
381
      bfd_set_error (bfd_error_no_memory);
407
408
void
408
409
bfd_hash_table_free (struct bfd_hash_table *table)
409
410
{
410
 
  objalloc_free (table->memory);
 
411
  objalloc_free ((struct objalloc *) table->memory);
411
412
  table->memory = NULL;
412
413
}
413
414
 
453
454
 
454
455
  if (copy)
455
456
    {
456
 
      char *new;
 
457
      char *new_string;
457
458
 
458
 
      new = objalloc_alloc ((struct objalloc *) table->memory, len + 1);
459
 
      if (!new)
 
459
      new_string = (char *) objalloc_alloc ((struct objalloc *) table->memory,
 
460
                                            len + 1);
 
461
      if (!new_string)
460
462
        {
461
463
          bfd_set_error (bfd_error_no_memory);
462
464
          return NULL;
463
465
        }
464
 
      memcpy (new, string, len + 1);
465
 
      string = new;
 
466
      memcpy (new_string, string, len + 1);
 
467
      string = new_string;
466
468
    }
467
469
 
468
470
  return bfd_hash_insert (table, string, hash);
580
582
                  const char *string ATTRIBUTE_UNUSED)
581
583
{
582
584
  if (entry == NULL)
583
 
    entry = bfd_hash_allocate (table, sizeof (* entry));
 
585
    entry = (struct bfd_hash_entry *) bfd_hash_allocate (table,
 
586
                                                         sizeof (* entry));
584
587
  return entry;
585
588
}
586
589
 
675
678
  /* Allocate the structure if it has not already been allocated by a
676
679
     subclass.  */
677
680
  if (ret == NULL)
678
 
    ret = bfd_hash_allocate (table, sizeof (* ret));
 
681
    ret = (struct strtab_hash_entry *) bfd_hash_allocate (table,
 
682
                                                          sizeof (* ret));
679
683
  if (ret == NULL)
680
684
    return NULL;
681
685
 
707
711
  struct bfd_strtab_hash *table;
708
712
  bfd_size_type amt = sizeof (* table);
709
713
 
710
 
  table = bfd_malloc (amt);
 
714
  table = (struct bfd_strtab_hash *) bfd_malloc (amt);
711
715
  if (table == NULL)
712
716
    return NULL;
713
717
 
770
774
    }
771
775
  else
772
776
    {
773
 
      entry = bfd_hash_allocate (&tab->table, sizeof (* entry));
 
777
      entry = (struct strtab_hash_entry *) bfd_hash_allocate (&tab->table,
 
778
                                                              sizeof (* entry));
774
779
      if (entry == NULL)
775
780
        return (bfd_size_type) -1;
776
781
      if (! copy)
779
784
        {
780
785
          char *n;
781
786
 
782
 
          n = bfd_hash_allocate (&tab->table, strlen (str) + 1);
 
787
          n = (char *) bfd_hash_allocate (&tab->table, strlen (str) + 1);
783
788
          if (n == NULL)
784
789
            return (bfd_size_type) -1;
785
790
          entry->root.string = n;