Ignore:
Timestamp:
Aug 16, 2003, 6:59:22 PM (22 years ago)
Author:
bird
Message:

binutils v2.14 - offical sources.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/GNU/src/binutils/bfd/hash.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r608 r609  
    11/* hash.c -- hash table routines for BFD
    2    Copyright 1993, 1994, 1995, 1997, 1999, 2001
     2   Copyright 1993, 1994, 1995, 1997, 1999, 2001, 2002
    33   Free Software Foundation, Inc.
    44   Written by Steve Chamberlain <sac@cygnus.com>
     
    6868        entries you will need, the function <<bfd_hash_table_init_n>>,
    6969        which takes a @var{size} argument, may be used).
    70         <<bfd_hash_table_init>> returns <<false>> if some sort of
     70        <<bfd_hash_table_init>> returns <<FALSE>> if some sort of
    7171        error occurs.
    7272
     
    9797        string in the hash table and to create a new entry.
    9898
    99         If the @var{create} argument is <<false>>, <<bfd_hash_lookup>>
     99        If the @var{create} argument is <<FALSE>>, <<bfd_hash_lookup>>
    100100        will look up a string.  If the string is found, it will
    101101        returns a pointer to a <<struct bfd_hash_entry>>.  If the
     
    104104        the returns <<struct bfd_hash_entry>>.
    105105
    106         If the @var{create} argument is <<true>>, the string will be
     106        If the @var{create} argument is <<TRUE>>, the string will be
    107107        entered into the hash table if it is not already there.
    108108        Either way a pointer to a <<struct bfd_hash_entry>> will be
     
    111111        error occurred.
    112112
    113         If the @var{create} argument is <<true>>, and a new entry is
     113        If the @var{create} argument is <<TRUE>>, and a new entry is
    114114        created, the @var{copy} argument is used to decide whether to
    115115        copy the string onto the hash table objalloc or not.  If
    116         @var{copy} is passed as <<false>>, you must be careful not to
     116        @var{copy} is passed as <<FALSE>>, you must be careful not to
    117117        deallocate or modify the string as long as the hash table
    118118        exists.
     
    134134        must return a <<boolean>> value, which indicates whether to
    135135        continue traversing the hash table.  If the function returns
    136         <<false>>, <<bfd_hash_traverse>> will stop the traversal and
     136        <<FALSE>>, <<bfd_hash_traverse>> will stop the traversal and
    137137        return immediately.
    138138
     
    300300/* Create a new hash table, given a number of entries.  */
    301301
    302 boolean
     302bfd_boolean
    303303bfd_hash_table_init_n (table, newfunc, size)
    304304     struct bfd_hash_table *table;
     
    316316    {
    317317      bfd_set_error (bfd_error_no_memory);
    318       return false;
     318      return FALSE;
    319319    }
    320320  table->table = ((struct bfd_hash_entry **)
     
    323323    {
    324324      bfd_set_error (bfd_error_no_memory);
    325       return false;
     325      return FALSE;
    326326    }
    327327  memset ((PTR) table->table, 0, alloc);
    328328  table->size = size;
    329329  table->newfunc = newfunc;
    330   return true;
     330  return TRUE;
    331331}
    332332
    333333/* Create a new hash table with the default number of entries.  */
    334334
    335 boolean
     335bfd_boolean
    336336bfd_hash_table_init (table, newfunc)
    337337     struct bfd_hash_table *table;
     
    359359     struct bfd_hash_table *table;
    360360     const char *string;
    361      boolean create;
    362      boolean copy;
     361     bfd_boolean create;
     362     bfd_boolean copy;
    363363{
    364364  register const unsigned char *s;
     
    376376      hash += c + (c << 17);
    377377      hash ^= hash >> 2;
    378       ++len;
    379     }
     378    }
     379  len = (s - (const unsigned char *) string) - 1;
    380380  hash += len + (len << 17);
    381381  hash ^= hash >> 2;
     
    408408          return (struct bfd_hash_entry *) NULL;
    409409        }
    410       strcpy (new, string);
     410      memcpy (new, string, len + 1);
    411411      string = new;
    412412    }
     
    480480bfd_hash_traverse (table, func, info)
    481481     struct bfd_hash_table *table;
    482      boolean (*func) PARAMS ((struct bfd_hash_entry *, PTR));
     482     bfd_boolean (*func) PARAMS ((struct bfd_hash_entry *, PTR));
    483483     PTR info;
    484484{
     
    534534  /* Whether to precede strings with a two byte length, as in the
    535535     XCOFF .debug section.  */
    536   boolean xcoff;
     536  bfd_boolean xcoff;
    537537};
    538538
     
    584584{
    585585  struct bfd_strtab_hash *table;
    586 
    587   table = ((struct bfd_strtab_hash *)
    588            bfd_malloc (sizeof (struct bfd_strtab_hash)));
     586  bfd_size_type amt = sizeof (struct bfd_strtab_hash);
     587
     588  table = (struct bfd_strtab_hash *) bfd_malloc (amt);
    589589  if (table == NULL)
    590590    return NULL;
     
    599599  table->first = NULL;
    600600  table->last = NULL;
    601   table->xcoff = false;
     601  table->xcoff = FALSE;
    602602
    603603  return table;
     
    615615  ret = _bfd_stringtab_init ();
    616616  if (ret != NULL)
    617     ret->xcoff = true;
     617    ret->xcoff = TRUE;
    618618  return ret;
    619619}
     
    630630
    631631/* Get the index of a string in a strtab, adding it if it is not
    632    already present.  If HASH is false, we don't really use the hash
     632   already present.  If HASH is FALSE, we don't really use the hash
    633633   table, and we don't eliminate duplicate strings.  */
    634634
     
    637637     struct bfd_strtab_hash *tab;
    638638     const char *str;
    639      boolean hash;
    640      boolean copy;
     639     bfd_boolean hash;
     640     bfd_boolean copy;
    641641{
    642642  register struct strtab_hash_entry *entry;
     
    644644  if (hash)
    645645    {
    646       entry = strtab_hash_lookup (tab, str, true, copy);
     646      entry = strtab_hash_lookup (tab, str, TRUE, copy);
    647647      if (entry == NULL)
    648648        return (bfd_size_type) -1;
     
    701701   the file.  */
    702702
    703 boolean
     703bfd_boolean
    704704_bfd_stringtab_emit (abfd, tab)
    705705     register bfd *abfd;
    706706     struct bfd_strtab_hash *tab;
    707707{
    708   register boolean xcoff;
     708  register bfd_boolean xcoff;
    709709  register struct strtab_hash_entry *entry;
    710710
     
    713713  for (entry = tab->first; entry != NULL; entry = entry->next)
    714714    {
    715       register const char *str;
    716       register size_t len;
     715      const char *str;
     716      size_t len;
    717717
    718718      str = entry->root.string;
     
    724724
    725725          /* The output length includes the null byte.  */
    726           bfd_put_16 (abfd, len, buf);
    727           if (bfd_write ((PTR) buf, 1, 2, abfd) != 2)
    728             return false;
     726          bfd_put_16 (abfd, (bfd_vma) len, buf);
     727          if (bfd_bwrite ((PTR) buf, (bfd_size_type) 2, abfd) != 2)
     728            return FALSE;
    729729        }
    730730
    731       if (bfd_write ((PTR) str, 1, len, abfd) != len)
    732         return false;
    733     }
    734 
    735   return true;
    736 }
     731      if (bfd_bwrite ((PTR) str, (bfd_size_type) len, abfd) != len)
     732        return FALSE;
     733    }
     734
     735  return TRUE;
     736}
Note: See TracChangeset for help on using the changeset viewer.