deref_check: remove the --spammy option
[smatch.git] / cwchash / hashtable_private.h
blob3e95f600577540095d20b2551d1198556cf36361
1 /* Copyright (C) 2002, 2004 Christopher Clark <firstname.lastname@cl.cam.ac.uk> */
3 #ifndef __HASHTABLE_PRIVATE_CWC22_H__
4 #define __HASHTABLE_PRIVATE_CWC22_H__
6 #include "hashtable.h"
8 /*****************************************************************************/
9 struct entry
11 void *k, *v;
12 unsigned int h;
13 struct entry *next;
16 struct hashtable {
17 unsigned int tablelength;
18 struct entry **table;
19 unsigned int entrycount;
20 unsigned int loadlimit;
21 unsigned int primeindex;
22 unsigned int (*hashfn) (void *k);
23 int (*eqfn) (void *k1, void *k2);
26 /*****************************************************************************/
27 unsigned int
28 hash(struct hashtable *h, void *k);
30 /*****************************************************************************/
31 /* indexFor */
32 static inline unsigned int
33 indexFor(unsigned int tablelength, unsigned int hashvalue) {
34 return (hashvalue % tablelength);
37 /* Only works if tablelength == 2^N */
38 /*static inline unsigned int
39 indexFor(unsigned int tablelength, unsigned int hashvalue)
41 return (hashvalue & (tablelength - 1u));
45 /*****************************************************************************/
46 #define freekey(X) free(X)
47 /*define freekey(X) ; */
50 /*****************************************************************************/
52 #endif /* __HASHTABLE_PRIVATE_CWC22_H__*/
55 * Copyright (c) 2002, Christopher Clark
56 * All rights reserved.
58 * Redistribution and use in source and binary forms, with or without
59 * modification, are permitted provided that the following conditions
60 * are met:
62 * * Redistributions of source code must retain the above copyright
63 * notice, this list of conditions and the following disclaimer.
65 * * Redistributions in binary form must reproduce the above copyright
66 * notice, this list of conditions and the following disclaimer in the
67 * documentation and/or other materials provided with the distribution.
69 * * Neither the name of the original author; nor the names of any contributors
70 * may be used to endorse or promote products derived from this software
71 * without specific prior written permission.
74 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
75 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
76 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
77 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
78 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
79 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
80 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
81 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
82 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
83 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
84 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.