Back to index

glibc  2.9
simple-hash.h
Go to the documentation of this file.
00001 /* Copyright (C) 1995-1999, 2001, 2002, 2005 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003    Contributed by Ulrich Drepper <drepper@gnu.org>, 1995.
00004 
00005    This program is free software; you can redistribute it and/or modify
00006    it under the terms of the GNU General Public License as published
00007    by the Free Software Foundation; version 2 of the License, or
00008    (at your option) any later version.
00009 
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013    GNU General Public License for more details.
00014 
00015    You should have received a copy of the GNU General Public License
00016    along with this program; if not, write to the Free Software Foundation,
00017    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
00018 
00019 #ifndef _SIMPLE_HASH_H
00020 #define _SIMPLE_HASH_H
00021 
00022 #include <obstack.h>
00023 
00024 typedef struct hash_table
00025 {
00026   unsigned long int size;
00027   unsigned long int filled;
00028   void *first;
00029   void *table;
00030   struct obstack mem_pool;
00031 }
00032 hash_table;
00033 
00034 
00035 extern int init_hash (hash_table *htab, unsigned long int init_size) __THROW;
00036 extern int delete_hash (hash_table *htab) __THROW;
00037 extern int insert_entry (hash_table *htab, const void *key, size_t keylen,
00038                       void *data) __THROW;
00039 extern int find_entry (const hash_table *htab, const void *key, size_t keylen,
00040                      void **result) __THROW;
00041 extern int set_entry (hash_table *htab, const void *key, size_t keylen,
00042                     void *newval) __THROW;
00043 
00044 extern int iterate_table (const hash_table *htab, void **ptr,
00045                        const void **key, size_t *keylen, void **data)
00046      __THROW;
00047 
00048 extern unsigned long int compute_hashval (const void *key, size_t keylen)
00049      __THROW;
00050 extern unsigned long int next_prime (unsigned long int seed) __THROW;
00051 
00052 #endif /* simple-hash.h */