]> git.itanic.dy.fi Git - maemo-mapper/blob - src/hashtable_private.h
Added basic APRS support - Can be disabled by removing definition of INCLUDE_APRS
[maemo-mapper] / src / hashtable_private.h
1 /*
2  * 
3  * This file is part of Maemo Mapper.
4  *
5  * Maemo Mapper is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * Maemo Mapper is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with Maemo Mapper.  If not, see <http://www.gnu.org/licenses/>.
17  * 
18  * 
19  * Parts of this code have been ported from Xastir by Rob Williams (10 Aug 2008):
20  * 
21  *  * XASTIR, Amateur Station Tracking and Information Reporting
22  * Copyright (C) 1999,2000  Frank Giannandrea
23  * Copyright (C) 2000-2007  The Xastir Group
24  * Copyright (C) 2002, 2004 Christopher Clark <firstname.lastname@cl.cam.ac.uk> 
25  * 
26  */
27
28 #ifdef HAVE_CONFIG_H
29 #    include "config.h"
30 #endif
31
32 #ifdef INCLUDE_APRS
33
34 #ifndef __HASHTABLE_PRIVATE_CWC22_H__
35 #define __HASHTABLE_PRIVATE_CWC22_H__
36
37 #include "hashtable.h"
38
39
40 /*****************************************************************************/
41 struct entry
42 {
43     void *k, *v;
44     unsigned int h;
45     struct entry *next;
46 };
47
48 struct hashtable {
49     unsigned int tablelength;
50     struct entry **table;
51     unsigned int entrycount;
52     unsigned int loadlimit;
53     unsigned int primeindex;
54     unsigned int (*hashfn) (void *k);
55     int (*eqfn) (void *k1, void *k2);
56 };
57
58 /*****************************************************************************/
59 unsigned int
60 hash(struct hashtable *h, void *k);
61
62 /*****************************************************************************/
63 /* indexFor */
64 static inline unsigned int
65 indexFor(unsigned int tablelength, unsigned int hashvalue) {
66     return (hashvalue % tablelength);
67 }
68
69 /* Only works if tablelength == 2^N */
70 /*static inline unsigned int
71 indexFor(unsigned int tablelength, unsigned int hashvalue)
72 {
73     return (hashvalue & (tablelength - 1u));
74 }
75 */
76
77 /*****************************************************************************/
78 #define freekey(X) free(X)
79 /*define freekey(X) ; */
80
81
82 /*****************************************************************************/
83
84 #endif /* __HASHTABLE_PRIVATE_CWC22_H__*/
85
86
87 #endif // INCLUDE_APRS
88
89 /*
90  * Copyright (C) 2002 Christopher Clark <firstname.lastname@cl.cam.ac.uk>
91  *
92  * Permission is hereby granted, free of charge, to any person obtaining a copy
93  * of this software and associated documentation files (the "Software"), to
94  * deal in the Software without restriction, including without limitation the
95  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
96  * sell copies of the Software, and to permit persons to whom the Software is
97  * furnished to do so, subject to the following conditions:
98  *
99  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
100  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
101  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
102  * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
103  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
104  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
105  * */
106
107