hash.h revision 218822
112048Speter/* hash.h -- header file for gas hash table routines 212048Speter Copyright 1987, 1992, 1993, 1995, 1999, 2003 312048Speter Free Software Foundation, Inc. 412048Speter 512048Speter This file is part of GAS, the GNU Assembler. 612048Speter 712048Speter GAS is free software; you can redistribute it and/or modify 812048Speter it under the terms of the GNU General Public License as published by 912048Speter the Free Software Foundation; either version 2, or (at your option) 1012048Speter any later version. 1112048Speter 1212048Speter GAS is distributed in the hope that it will be useful, 1312048Speter but WITHOUT ANY WARRANTY; without even the implied warranty of 1412048Speter MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1512048Speter GNU General Public License for more details. 1612048Speter 1712048Speter You should have received a copy of the GNU General Public License 1812048Speter along with GAS; see the file COPYING. If not, write to the Free 1912048Speter Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 2012048Speter 02110-1301, USA. */ 2112048Speter 2212048Speter#ifndef HASH_H 2312048Speter#define HASH_H 2412048Speter 2512048Speterstruct hash_control; 2612048Speter 2712048Speter/* Set the size of the hash table used. */ 2812048Speter 2912048Spetervoid set_gas_hash_table_size (unsigned long); 3012048Speter 3112048Speter/* Create a hash table. This return a control block. */ 3237001Scharnier 3350476Speterextern struct hash_control *hash_new (void); 3412048Speter 3512048Speter/* Delete a hash table, freeing all allocated memory. */ 3674594Salfred 3712048Speterextern void hash_die (struct hash_control *); 3837001Scharnier 3912048Speter/* Insert an entry into a hash table. This returns NULL on success. 4012048Speter On error, it returns a printable string indicating the error. It 41122621Sjohan is considered to be an error if the entry already exists in the 4212048Speter hash table. */ 4337001Scharnier 44122621Sjohanextern const char *hash_insert (struct hash_control *, 4512048Speter const char *key, PTR value); 4612048Speter 4774594Salfred/* Insert or replace an entry in a hash table. This returns NULL on 4812048Speter success. On error, it returns a printable string indicating the 4989827Sjoerg error. If an entry already exists, its value is replaced. */ 5089827Sjoerg 5112048Speterextern const char *hash_jam (struct hash_control *, 5212048Speter const char *key, PTR value); 5312048Speter 5492881Simp/* Replace an existing entry in a hash table. This returns the old 55207141Sjeff value stored for the entry. If the entry is not found in the hash 5698542Smckusick table, this does nothing and returns NULL. */ 5789827Sjoerg 5812048Speterextern PTR hash_replace (struct hash_control *, const char *key, 5992881Simp PTR value); 6012048Speter 6112048Speter/* Find an entry in a hash table, returning its value. Returns NULL 6212048Speter if the entry is not found. */ 6312048Speter 6412048Speterextern PTR hash_find (struct hash_control *, const char *key); 6512048Speter 6612048Speter/* As hash_find, but KEY is of length LEN and is not guaranteed to be 6712048Speter NUL-terminated. */ 6812048Speter 6912048Speterextern PTR hash_find_n (struct hash_control *, const char *key, size_t len); 7012048Speter 7112048Speter/* Delete an entry from a hash table. This returns the value stored 7212048Speter for that entry, or NULL if there is no such entry. */ 7312048Speter 7412048Speterextern PTR hash_delete (struct hash_control *, const char *key); 7512048Speter 7689791Sgreen/* Traverse a hash table. Call the function on every entry in the 7792881Simp hash table. */ 7889791Sgreen 7989791Sgreenextern void hash_traverse (struct hash_control *, 8089791Sgreen void (*pfn) (const char *key, PTR value)); 8189791Sgreen 8289791Sgreen/* Print hash table statistics on the specified file. NAME is the 8389791Sgreen name of the hash table, used for printing a header. */ 8489791Sgreen 8589791Sgreenextern void hash_print_statistics (FILE *, const char *name, 8689791Sgreen struct hash_control *); 8789791Sgreen 8889791Sgreen#endif /* HASH_H */ 8989791Sgreen