Browse code

core: use const char*/str* for hash functions

Andrei Pelinescu-Onciul authored on 26/08/2010 19:40:45
Showing 2 changed files
... ...
@@ -83,7 +83,7 @@
83 83
 /* "raw" 2 strings hash
84 84
  * returns an unsigned int (which you can use modulo table_size as hash value)
85 85
  */
86
-inline static unsigned int get_hash2_raw(str* key1, str* key2)
86
+inline static unsigned int get_hash2_raw(const str* key1, const str* key2)
87 87
 {
88 88
 	char* p;
89 89
 	register unsigned v;
... ...
@@ -101,9 +101,9 @@ inline static unsigned int get_hash2_raw(str* key1, str* key2)
101 101
 /* "raw" 1 string hash
102 102
  * returns an unsigned int (which you can use modulo table_size as hash value)
103 103
  */
104
-inline static unsigned int get_hash1_raw(char* s, int len)
104
+inline static unsigned int get_hash1_raw(const char* s, int len)
105 105
 {
106
-	char* p;
106
+	const char* p;
107 107
 	register unsigned v;
108 108
 	register unsigned h;
109 109
 	
... ...
@@ -148,9 +148,9 @@ inline static unsigned int get_hash1_raw(char* s, int len)
148 148
 
149 149
 /* a little slower than get_hash1_raw() , but better distribution for 
150 150
  * numbers and about the same for strings */
151
-inline static unsigned int get_hash1_raw2(char* s, int len)
151
+inline static unsigned int get_hash1_raw2(const char* s, int len)
152 152
 {
153
-	char* p;
153
+	const char* p;
154 154
 	register unsigned v;
155 155
 	register unsigned h;
156 156
 	
... ...
@@ -165,7 +165,7 @@ inline static unsigned int get_hash1_raw2(char* s, int len)
165 165
 /* "raw" 2 strings hash optimized for numeric strings (see above)
166 166
  * returns an unsigned int (which you can use modulo table_size as hash value)
167 167
  */
168
-inline static unsigned int get_hash2_raw2(str* key1, str* key2)
168
+inline static unsigned int get_hash2_raw2(const str* key1, const str* key2)
169 169
 {
170 170
 	char* p;
171 171
 	register unsigned v;
... ...
@@ -184,7 +184,7 @@ inline static unsigned int get_hash2_raw2(str* key1, str* key2)
184 184
  * insensitive)
185 185
  * returns an unsigned int (which you can use modulo table_size as hash value)
186 186
  */
187
-inline static unsigned int get_hash2_case_raw(str* key1, str* key2)
187
+inline static unsigned int get_hash2_case_raw(const str* key1, const str* key2)
188 188
 {
189 189
 	char* p;
190 190
 	register unsigned v;
... ...
@@ -202,9 +202,9 @@ inline static unsigned int get_hash2_case_raw(str* key1, str* key2)
202 202
 /* "raw" 1 string case insensitive hash
203 203
  * returns an unsigned int (which you can use modulo table_size as hash value)
204 204
  */
205
-inline static unsigned int get_hash1_case_raw(char* s, int len)
205
+inline static unsigned int get_hash1_case_raw(const char* s, int len)
206 206
 {
207
-	char* p;
207
+	const char* p;
208 208
 	register unsigned v;
209 209
 	register unsigned h;
210 210
 	
... ...
@@ -218,9 +218,9 @@ inline static unsigned int get_hash1_case_raw(char* s, int len)
218 218
 /* same as get_hash1_raw2, but case insensitive and slower
219 219
  * returns an unsigned int (which you can use modulo table_size as hash value)
220 220
  */
221
-inline static unsigned int get_hash1_case_raw2(char* s, int len)
221
+inline static unsigned int get_hash1_case_raw2(const char* s, int len)
222 222
 {
223
-	char* p;
223
+	const char* p;
224 224
 	register unsigned v;
225 225
 	register unsigned h;
226 226
 	
... ...
@@ -236,7 +236,8 @@ inline static unsigned int get_hash1_case_raw2(char* s, int len)
236 236
  * same as get_hash2_raw2 but case insensitive and slower
237 237
  * returns an unsigned int (which you can use modulo table_size as hash value)
238 238
  */
239
-inline static unsigned int get_hash2_case_raw2(str* key1, str* key2)
239
+inline static unsigned int get_hash2_case_raw2(const str* key1,
240
+											   const str* key2)
240 241
 {
241 242
 	char* p;
242 243
 	register unsigned v;
... ...
@@ -96,7 +96,7 @@ inline static void str_hash_add(struct str_hash_table* ht,
96 96
 
97 97
 
98 98
 inline static struct str_hash_entry* str_hash_get(struct str_hash_table* ht,
99
-									char* key, int len)
99
+									const char* key, int len)
100 100
 {
101 101
 	int h;
102 102
 	struct str_hash_entry* e;