X-Git-Url: https://oss.titaniummirror.com/gitweb?p=msp430-binutils.git;a=blobdiff_plain;f=gas%2Fhash.c;fp=gas%2Fhash.c;h=9d71ba8d4e2e2c5c6fc65a7f4222b0ee0276426c;hp=3ef582ddf623a44d7dfd8d51effca6f6ebd7911f;hb=d5da4f291af551c0b8b79e1d4a9b173d60e5c10e;hpb=7b5ea4fcdf2819e070665ab5610f8b48e3867c10 diff --git a/gas/hash.c b/gas/hash.c index 3ef582d..9d71ba8 100644 --- a/gas/hash.c +++ b/gas/hash.c @@ -1,6 +1,6 @@ /* hash.c -- gas hash table code Copyright 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, - 2000, 2001, 2002, 2003, 2005, 2007 + 2000, 2001, 2002, 2003, 2005, 2007, 2008 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -44,7 +44,7 @@ struct hash_entry { table. */ unsigned long hash; /* Pointer being stored in the hash table. */ - PTR data; + void *data; }; /* A hash table. */ @@ -113,10 +113,10 @@ hash_new (void) size = get_gas_hash_table_size (); - ret = xmalloc (sizeof *ret); + ret = (struct hash_control *) xmalloc (sizeof *ret); obstack_begin (&ret->memory, chunksize); alloc = size * sizeof (struct hash_entry *); - ret->table = obstack_alloc (&ret->memory, alloc); + ret->table = (struct hash_entry **) obstack_alloc (&ret->memory, alloc); memset (ret->table, 0, alloc); ret->size = size; @@ -223,7 +223,7 @@ hash_lookup (struct hash_control *table, const char *key, size_t len, hash table. */ const char * -hash_insert (struct hash_control *table, const char *key, PTR value) +hash_insert (struct hash_control *table, const char *key, void *value) { struct hash_entry *p; struct hash_entry **list; @@ -253,7 +253,7 @@ hash_insert (struct hash_control *table, const char *key, PTR value) error. If an entry already exists, its value is replaced. */ const char * -hash_jam (struct hash_control *table, const char *key, PTR value) +hash_jam (struct hash_control *table, const char *key, void *value) { struct hash_entry *p; struct hash_entry **list; @@ -290,11 +290,11 @@ hash_jam (struct hash_control *table, const char *key, PTR value) value stored for the entry. If the entry is not found in the hash table, this does nothing and returns NULL. */ -PTR -hash_replace (struct hash_control *table, const char *key, PTR value) +void * +hash_replace (struct hash_control *table, const char *key, void *value) { struct hash_entry *p; - PTR ret; + void *ret; p = hash_lookup (table, key, strlen (key), NULL, NULL); if (p == NULL) @@ -314,7 +314,7 @@ hash_replace (struct hash_control *table, const char *key, PTR value) /* Find an entry in a hash table, returning its value. Returns NULL if the entry is not found. */ -PTR +void * hash_find (struct hash_control *table, const char *key) { struct hash_entry *p; @@ -329,7 +329,7 @@ hash_find (struct hash_control *table, const char *key) /* As hash_find, but KEY is of length LEN and is not guaranteed to be NUL-terminated. */ -PTR +void * hash_find_n (struct hash_control *table, const char *key, size_t len) { struct hash_entry *p; @@ -344,8 +344,8 @@ hash_find_n (struct hash_control *table, const char *key, size_t len) /* Delete an entry from a hash table. This returns the value stored for that entry, or NULL if there is no such entry. */ -PTR -hash_delete (struct hash_control *table, const char *key) +void * +hash_delete (struct hash_control *table, const char *key, int freeme) { struct hash_entry *p; struct hash_entry **list; @@ -363,9 +363,8 @@ hash_delete (struct hash_control *table, const char *key) *list = p->next; - /* Note that we never reclaim the memory for this entry. If gas - ever starts deleting hash table entries in a big way, this will - have to change. */ + if (freeme) + obstack_free (&table->memory, p); return p->data; } @@ -375,7 +374,7 @@ hash_delete (struct hash_control *table, const char *key) void hash_traverse (struct hash_control *table, - void (*pfn) (const char *key, PTR value)) + void (*pfn) (const char *key, void *value)) { unsigned int i;