Changeset 609 for branches/GNU/src/binutils/bfd/hash.c
- Timestamp:
- Aug 16, 2003, 6:59:22 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/binutils/bfd/hash.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 1 /* hash.c -- hash table routines for BFD 2 Copyright 1993, 1994, 1995, 1997, 1999, 2001 2 Copyright 1993, 1994, 1995, 1997, 1999, 2001, 2002 3 3 Free Software Foundation, Inc. 4 4 Written by Steve Chamberlain <sac@cygnus.com> … … 68 68 entries you will need, the function <<bfd_hash_table_init_n>>, 69 69 which takes a @var{size} argument, may be used). 70 <<bfd_hash_table_init>> returns << false>> if some sort of70 <<bfd_hash_table_init>> returns <<FALSE>> if some sort of 71 71 error occurs. 72 72 … … 97 97 string in the hash table and to create a new entry. 98 98 99 If the @var{create} argument is << false>>, <<bfd_hash_lookup>>99 If the @var{create} argument is <<FALSE>>, <<bfd_hash_lookup>> 100 100 will look up a string. If the string is found, it will 101 101 returns a pointer to a <<struct bfd_hash_entry>>. If the … … 104 104 the returns <<struct bfd_hash_entry>>. 105 105 106 If the @var{create} argument is << true>>, the string will be106 If the @var{create} argument is <<TRUE>>, the string will be 107 107 entered into the hash table if it is not already there. 108 108 Either way a pointer to a <<struct bfd_hash_entry>> will be … … 111 111 error occurred. 112 112 113 If the @var{create} argument is << true>>, and a new entry is113 If the @var{create} argument is <<TRUE>>, and a new entry is 114 114 created, the @var{copy} argument is used to decide whether to 115 115 copy the string onto the hash table objalloc or not. If 116 @var{copy} is passed as << false>>, you must be careful not to116 @var{copy} is passed as <<FALSE>>, you must be careful not to 117 117 deallocate or modify the string as long as the hash table 118 118 exists. … … 134 134 must return a <<boolean>> value, which indicates whether to 135 135 continue traversing the hash table. If the function returns 136 << false>>, <<bfd_hash_traverse>> will stop the traversal and136 <<FALSE>>, <<bfd_hash_traverse>> will stop the traversal and 137 137 return immediately. 138 138 … … 300 300 /* Create a new hash table, given a number of entries. */ 301 301 302 b oolean302 bfd_boolean 303 303 bfd_hash_table_init_n (table, newfunc, size) 304 304 struct bfd_hash_table *table; … … 316 316 { 317 317 bfd_set_error (bfd_error_no_memory); 318 return false;318 return FALSE; 319 319 } 320 320 table->table = ((struct bfd_hash_entry **) … … 323 323 { 324 324 bfd_set_error (bfd_error_no_memory); 325 return false;325 return FALSE; 326 326 } 327 327 memset ((PTR) table->table, 0, alloc); 328 328 table->size = size; 329 329 table->newfunc = newfunc; 330 return true;330 return TRUE; 331 331 } 332 332 333 333 /* Create a new hash table with the default number of entries. */ 334 334 335 b oolean335 bfd_boolean 336 336 bfd_hash_table_init (table, newfunc) 337 337 struct bfd_hash_table *table; … … 359 359 struct bfd_hash_table *table; 360 360 const char *string; 361 b oolean create;362 b oolean copy;361 bfd_boolean create; 362 bfd_boolean copy; 363 363 { 364 364 register const unsigned char *s; … … 376 376 hash += c + (c << 17); 377 377 hash ^= hash >> 2; 378 ++len;379 }378 } 379 len = (s - (const unsigned char *) string) - 1; 380 380 hash += len + (len << 17); 381 381 hash ^= hash >> 2; … … 408 408 return (struct bfd_hash_entry *) NULL; 409 409 } 410 strcpy (new, string);410 memcpy (new, string, len + 1); 411 411 string = new; 412 412 } … … 480 480 bfd_hash_traverse (table, func, info) 481 481 struct bfd_hash_table *table; 482 b oolean (*func) PARAMS ((struct bfd_hash_entry *, PTR));482 bfd_boolean (*func) PARAMS ((struct bfd_hash_entry *, PTR)); 483 483 PTR info; 484 484 { … … 534 534 /* Whether to precede strings with a two byte length, as in the 535 535 XCOFF .debug section. */ 536 b oolean xcoff;536 bfd_boolean xcoff; 537 537 }; 538 538 … … 584 584 { 585 585 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); 589 589 if (table == NULL) 590 590 return NULL; … … 599 599 table->first = NULL; 600 600 table->last = NULL; 601 table->xcoff = false;601 table->xcoff = FALSE; 602 602 603 603 return table; … … 615 615 ret = _bfd_stringtab_init (); 616 616 if (ret != NULL) 617 ret->xcoff = true;617 ret->xcoff = TRUE; 618 618 return ret; 619 619 } … … 630 630 631 631 /* 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 hash632 already present. If HASH is FALSE, we don't really use the hash 633 633 table, and we don't eliminate duplicate strings. */ 634 634 … … 637 637 struct bfd_strtab_hash *tab; 638 638 const char *str; 639 b oolean hash;640 b oolean copy;639 bfd_boolean hash; 640 bfd_boolean copy; 641 641 { 642 642 register struct strtab_hash_entry *entry; … … 644 644 if (hash) 645 645 { 646 entry = strtab_hash_lookup (tab, str, true, copy);646 entry = strtab_hash_lookup (tab, str, TRUE, copy); 647 647 if (entry == NULL) 648 648 return (bfd_size_type) -1; … … 701 701 the file. */ 702 702 703 b oolean703 bfd_boolean 704 704 _bfd_stringtab_emit (abfd, tab) 705 705 register bfd *abfd; 706 706 struct bfd_strtab_hash *tab; 707 707 { 708 register b oolean xcoff;708 register bfd_boolean xcoff; 709 709 register struct strtab_hash_entry *entry; 710 710 … … 713 713 for (entry = tab->first; entry != NULL; entry = entry->next) 714 714 { 715 registerconst char *str;716 registersize_t len;715 const char *str; 716 size_t len; 717 717 718 718 str = entry->root.string; … … 724 724 725 725 /* 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; 729 729 } 730 730 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 } -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.