Back to index

cell-binutils  2.17cvs20070401
hash.h
Go to the documentation of this file.
00001 /* hash.h -- header file for gas hash table routines
00002    Copyright 1987, 1992, 1993, 1995, 1999, 2003
00003    Free Software Foundation, Inc.
00004 
00005    This file is part of GAS, the GNU Assembler.
00006 
00007    GAS is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License as published by
00009    the Free Software Foundation; either version 2, or (at your option)
00010    any later version.
00011 
00012    GAS is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015    GNU General Public License for more details.
00016 
00017    You should have received a copy of the GNU General Public License
00018    along with GAS; see the file COPYING.  If not, write to the Free
00019    Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
00020    02110-1301, USA.  */
00021 
00022 #ifndef HASH_H
00023 #define HASH_H
00024 
00025 struct hash_control;
00026 
00027 /* Set the size of the hash table used.  */
00028 
00029 void set_gas_hash_table_size (unsigned long);
00030 
00031 /* Create a hash table.  This return a control block.  */
00032 
00033 extern struct hash_control *hash_new (void);
00034 
00035 /* Delete a hash table, freeing all allocated memory.  */
00036 
00037 extern void hash_die (struct hash_control *);
00038 
00039 /* Insert an entry into a hash table.  This returns NULL on success.
00040    On error, it returns a printable string indicating the error.  It
00041    is considered to be an error if the entry already exists in the
00042    hash table.  */
00043 
00044 extern const char *hash_insert (struct hash_control *,
00045                             const char *key, PTR value);
00046 
00047 /* Insert or replace an entry in a hash table.  This returns NULL on
00048    success.  On error, it returns a printable string indicating the
00049    error.  If an entry already exists, its value is replaced.  */
00050 
00051 extern const char *hash_jam (struct hash_control *,
00052                           const char *key, PTR value);
00053 
00054 /* Replace an existing entry in a hash table.  This returns the old
00055    value stored for the entry.  If the entry is not found in the hash
00056    table, this does nothing and returns NULL.  */
00057 
00058 extern PTR hash_replace (struct hash_control *, const char *key,
00059                       PTR value);
00060 
00061 /* Find an entry in a hash table, returning its value.  Returns NULL
00062    if the entry is not found.  */
00063 
00064 extern PTR hash_find (struct hash_control *, const char *key);
00065 
00066 /* As hash_find, but KEY is of length LEN and is not guaranteed to be
00067    NUL-terminated.  */
00068 
00069 extern PTR hash_find_n (struct hash_control *, const char *key, size_t len);
00070 
00071 /* Delete an entry from a hash table.  This returns the value stored
00072    for that entry, or NULL if there is no such entry.  */
00073 
00074 extern PTR hash_delete (struct hash_control *, const char *key);
00075 
00076 /* Traverse a hash table.  Call the function on every entry in the
00077    hash table.  */
00078 
00079 extern void hash_traverse (struct hash_control *,
00080                         void (*pfn) (const char *key, PTR value));
00081 
00082 /* Print hash table statistics on the specified file.  NAME is the
00083    name of the hash table, used for printing a header.  */
00084 
00085 extern void hash_print_statistics (FILE *, const char *name,
00086                                struct hash_control *);
00087 
00088 #endif /* HASH_H */