Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/coreutils/src/gnulib/lib/hash.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||||||||
2 | - | |||||||||||||||||||||||||
3 | - | |||||||||||||||||||||||||
4 | - | |||||||||||||||||||||||||
5 | - | |||||||||||||||||||||||||
6 | struct hash_entry | - | ||||||||||||||||||||||||
7 | { | - | ||||||||||||||||||||||||
8 | void *data; | - | ||||||||||||||||||||||||
9 | struct hash_entry *next; | - | ||||||||||||||||||||||||
10 | }; | - | ||||||||||||||||||||||||
11 | - | |||||||||||||||||||||||||
12 | struct hash_table | - | ||||||||||||||||||||||||
13 | { | - | ||||||||||||||||||||||||
14 | - | |||||||||||||||||||||||||
15 | - | |||||||||||||||||||||||||
16 | - | |||||||||||||||||||||||||
17 | struct hash_entry *bucket; | - | ||||||||||||||||||||||||
18 | struct hash_entry const *bucket_limit; | - | ||||||||||||||||||||||||
19 | size_t n_buckets; | - | ||||||||||||||||||||||||
20 | size_t n_buckets_used; | - | ||||||||||||||||||||||||
21 | size_t n_entries; | - | ||||||||||||||||||||||||
22 | - | |||||||||||||||||||||||||
23 | - | |||||||||||||||||||||||||
24 | const Hash_tuning *tuning; | - | ||||||||||||||||||||||||
25 | - | |||||||||||||||||||||||||
26 | - | |||||||||||||||||||||||||
27 | - | |||||||||||||||||||||||||
28 | - | |||||||||||||||||||||||||
29 | - | |||||||||||||||||||||||||
30 | - | |||||||||||||||||||||||||
31 | Hash_hasher hasher; | - | ||||||||||||||||||||||||
32 | Hash_comparator comparator; | - | ||||||||||||||||||||||||
33 | Hash_data_freer data_freer; | - | ||||||||||||||||||||||||
34 | - | |||||||||||||||||||||||||
35 | - | |||||||||||||||||||||||||
36 | struct hash_entry *free_entry_list; | - | ||||||||||||||||||||||||
37 | - | |||||||||||||||||||||||||
38 | - | |||||||||||||||||||||||||
39 | - | |||||||||||||||||||||||||
40 | - | |||||||||||||||||||||||||
41 | - | |||||||||||||||||||||||||
42 | - | |||||||||||||||||||||||||
43 | - | |||||||||||||||||||||||||
44 | }; | - | ||||||||||||||||||||||||
45 | static const Hash_tuning default_tuning = | - | ||||||||||||||||||||||||
46 | { | - | ||||||||||||||||||||||||
47 | 0.0f, | - | ||||||||||||||||||||||||
48 | 1.0f, | - | ||||||||||||||||||||||||
49 | 0.8f, | - | ||||||||||||||||||||||||
50 | 1.414f, | - | ||||||||||||||||||||||||
51 | - | |||||||||||||||||||||||||
52 | 0 | - | ||||||||||||||||||||||||
53 | - | |||||||||||||||||||||||||
54 | }; | - | ||||||||||||||||||||||||
55 | size_t | - | ||||||||||||||||||||||||
56 | hash_get_n_buckets (const Hash_table *table) | - | ||||||||||||||||||||||||
57 | { | - | ||||||||||||||||||||||||
58 | return never executed: table->n_buckets;return table->n_buckets; never executed: return table->n_buckets; | 0 | ||||||||||||||||||||||||
59 | } | - | ||||||||||||||||||||||||
60 | - | |||||||||||||||||||||||||
61 | - | |||||||||||||||||||||||||
62 | - | |||||||||||||||||||||||||
63 | size_t | - | ||||||||||||||||||||||||
64 | hash_get_n_buckets_used (const Hash_table *table) | - | ||||||||||||||||||||||||
65 | { | - | ||||||||||||||||||||||||
66 | return never executed: table->n_buckets_used;return table->n_buckets_used; never executed: return table->n_buckets_used; | 0 | ||||||||||||||||||||||||
67 | } | - | ||||||||||||||||||||||||
68 | - | |||||||||||||||||||||||||
69 | - | |||||||||||||||||||||||||
70 | - | |||||||||||||||||||||||||
71 | size_t | - | ||||||||||||||||||||||||
72 | hash_get_n_entries (const Hash_table *table) | - | ||||||||||||||||||||||||
73 | { | - | ||||||||||||||||||||||||
74 | return executed 13 times by 2 tests: table->n_entries;return table->n_entries; Executed by:
executed 13 times by 2 tests: return table->n_entries; Executed by:
| 13 | ||||||||||||||||||||||||
75 | } | - | ||||||||||||||||||||||||
76 | - | |||||||||||||||||||||||||
77 | - | |||||||||||||||||||||||||
78 | - | |||||||||||||||||||||||||
79 | size_t | - | ||||||||||||||||||||||||
80 | hash_get_max_bucket_length (const Hash_table *table) | - | ||||||||||||||||||||||||
81 | { | - | ||||||||||||||||||||||||
82 | struct hash_entry const *bucket; | - | ||||||||||||||||||||||||
83 | size_t max_bucket_length = 0; | - | ||||||||||||||||||||||||
84 | - | |||||||||||||||||||||||||
85 | for (bucket = table->bucket; bucket < table->bucket_limit
| 0 | ||||||||||||||||||||||||
86 | { | - | ||||||||||||||||||||||||
87 | if (bucket->data
| 0 | ||||||||||||||||||||||||
88 | { | - | ||||||||||||||||||||||||
89 | struct hash_entry const *cursor = bucket; | - | ||||||||||||||||||||||||
90 | size_t bucket_length = 1; | - | ||||||||||||||||||||||||
91 | - | |||||||||||||||||||||||||
92 | while (cursor = cursor->next, cursor
| 0 | ||||||||||||||||||||||||
93 | bucket_length++; never executed: bucket_length++; | 0 | ||||||||||||||||||||||||
94 | - | |||||||||||||||||||||||||
95 | if (bucket_length > max_bucket_length
| 0 | ||||||||||||||||||||||||
96 | max_bucket_length = bucket_length; never executed: max_bucket_length = bucket_length; | 0 | ||||||||||||||||||||||||
97 | } never executed: end of block | 0 | ||||||||||||||||||||||||
98 | } never executed: end of block | 0 | ||||||||||||||||||||||||
99 | - | |||||||||||||||||||||||||
100 | return never executed: max_bucket_length;return max_bucket_length; never executed: return max_bucket_length; | 0 | ||||||||||||||||||||||||
101 | } | - | ||||||||||||||||||||||||
102 | - | |||||||||||||||||||||||||
103 | - | |||||||||||||||||||||||||
104 | - | |||||||||||||||||||||||||
105 | - | |||||||||||||||||||||||||
106 | - | |||||||||||||||||||||||||
107 | _Bool | - | ||||||||||||||||||||||||
108 | - | |||||||||||||||||||||||||
109 | hash_table_ok (const Hash_table *table) | - | ||||||||||||||||||||||||
110 | { | - | ||||||||||||||||||||||||
111 | struct hash_entry const *bucket; | - | ||||||||||||||||||||||||
112 | size_t n_buckets_used = 0; | - | ||||||||||||||||||||||||
113 | size_t n_entries = 0; | - | ||||||||||||||||||||||||
114 | - | |||||||||||||||||||||||||
115 | for (bucket = table->bucket; bucket < table->bucket_limit
| 0 | ||||||||||||||||||||||||
116 | { | - | ||||||||||||||||||||||||
117 | if (bucket->data
| 0 | ||||||||||||||||||||||||
118 | { | - | ||||||||||||||||||||||||
119 | struct hash_entry const *cursor = bucket; | - | ||||||||||||||||||||||||
120 | - | |||||||||||||||||||||||||
121 | - | |||||||||||||||||||||||||
122 | n_buckets_used++; | - | ||||||||||||||||||||||||
123 | n_entries++; | - | ||||||||||||||||||||||||
124 | - | |||||||||||||||||||||||||
125 | - | |||||||||||||||||||||||||
126 | while (cursor = cursor->next, cursor
| 0 | ||||||||||||||||||||||||
127 | n_entries++; never executed: n_entries++; | 0 | ||||||||||||||||||||||||
128 | } never executed: end of block | 0 | ||||||||||||||||||||||||
129 | } never executed: end of block | 0 | ||||||||||||||||||||||||
130 | - | |||||||||||||||||||||||||
131 | if (n_buckets_used == table->n_buckets_used
| 0 | ||||||||||||||||||||||||
132 | return never executed: return 1 ; never executed: return 1 ; | 0 | ||||||||||||||||||||||||
133 | 1 never executed: return 1 ; | 0 | ||||||||||||||||||||||||
134 | ; never executed: return 1 ; | 0 | ||||||||||||||||||||||||
135 | - | |||||||||||||||||||||||||
136 | return never executed: return 0 ; never executed: return 0 ; | 0 | ||||||||||||||||||||||||
137 | 0 never executed: return 0 ; | 0 | ||||||||||||||||||||||||
138 | ; never executed: return 0 ; | 0 | ||||||||||||||||||||||||
139 | } | - | ||||||||||||||||||||||||
140 | - | |||||||||||||||||||||||||
141 | void | - | ||||||||||||||||||||||||
142 | hash_print_statistics (const Hash_table *table, FILE *stream) | - | ||||||||||||||||||||||||
143 | { | - | ||||||||||||||||||||||||
144 | size_t n_entries = hash_get_n_entries (table); | - | ||||||||||||||||||||||||
145 | size_t n_buckets = hash_get_n_buckets (table); | - | ||||||||||||||||||||||||
146 | size_t n_buckets_used = hash_get_n_buckets_used (table); | - | ||||||||||||||||||||||||
147 | size_t max_bucket_length = hash_get_max_bucket_length (table); | - | ||||||||||||||||||||||||
148 | - | |||||||||||||||||||||||||
149 | fprintf (stream, "# entries: %lu\n", (unsigned long int) n_entries); | - | ||||||||||||||||||||||||
150 | fprintf (stream, "# buckets: %lu\n", (unsigned long int) n_buckets); | - | ||||||||||||||||||||||||
151 | fprintf (stream, "# buckets used: %lu (%.2f%%)\n", | - | ||||||||||||||||||||||||
152 | (unsigned long int) n_buckets_used, | - | ||||||||||||||||||||||||
153 | (100.0 * n_buckets_used) / n_buckets); | - | ||||||||||||||||||||||||
154 | fprintf (stream, "max bucket length: %lu\n", | - | ||||||||||||||||||||||||
155 | (unsigned long int) max_bucket_length); | - | ||||||||||||||||||||||||
156 | } never executed: end of block | 0 | ||||||||||||||||||||||||
157 | - | |||||||||||||||||||||||||
158 | - | |||||||||||||||||||||||||
159 | - | |||||||||||||||||||||||||
160 | static struct hash_entry * | - | ||||||||||||||||||||||||
161 | safe_hasher (const Hash_table *table, const void *key) | - | ||||||||||||||||||||||||
162 | { | - | ||||||||||||||||||||||||
163 | size_t n = table->hasher (key, table->n_buckets); | - | ||||||||||||||||||||||||
164 | if (! (n < table->n_buckets)
| 0-99761 | ||||||||||||||||||||||||
165 | abort (); never executed: abort (); | 0 | ||||||||||||||||||||||||
166 | return executed 99761 times by 16 tests: table->bucket + n;return table->bucket + n; Executed by:
executed 99761 times by 16 tests: return table->bucket + n; Executed by:
| 99761 | ||||||||||||||||||||||||
167 | } | - | ||||||||||||||||||||||||
168 | - | |||||||||||||||||||||||||
169 | - | |||||||||||||||||||||||||
170 | - | |||||||||||||||||||||||||
171 | - | |||||||||||||||||||||||||
172 | void * | - | ||||||||||||||||||||||||
173 | hash_lookup (const Hash_table *table, const void *entry) | - | ||||||||||||||||||||||||
174 | { | - | ||||||||||||||||||||||||
175 | struct hash_entry const *bucket = safe_hasher (table, entry); | - | ||||||||||||||||||||||||
176 | struct hash_entry const *cursor; | - | ||||||||||||||||||||||||
177 | - | |||||||||||||||||||||||||
178 | if (bucket->data ==
| 3218-37175 | ||||||||||||||||||||||||
179 | ((void *)0)
| 3218-37175 | ||||||||||||||||||||||||
180 | ) | - | ||||||||||||||||||||||||
181 | return executed 37175 times by 12 tests: return ((void *)0) ; Executed by:
executed 37175 times by 12 tests: return ((void *)0) ; Executed by:
| 37175 | ||||||||||||||||||||||||
182 | ((void *)0) executed 37175 times by 12 tests: return ((void *)0) ; Executed by:
| 37175 | ||||||||||||||||||||||||
183 | ; executed 37175 times by 12 tests: return ((void *)0) ; Executed by:
| 37175 | ||||||||||||||||||||||||
184 | - | |||||||||||||||||||||||||
185 | for (cursor = bucket; cursor
| 2579-4575 | ||||||||||||||||||||||||
186 | if (entry == cursor->data
| 0-4575 | ||||||||||||||||||||||||
187 | return executed 639 times by 9 tests: cursor->data;return cursor->data; Executed by:
executed 639 times by 9 tests: return cursor->data; Executed by:
| 639 | ||||||||||||||||||||||||
188 | - | |||||||||||||||||||||||||
189 | return executed 2579 times by 5 tests: return ((void *)0) ; Executed by:
executed 2579 times by 5 tests: return ((void *)0) ; Executed by:
| 2579 | ||||||||||||||||||||||||
190 | ((void *)0) executed 2579 times by 5 tests: return ((void *)0) ; Executed by:
| 2579 | ||||||||||||||||||||||||
191 | ; executed 2579 times by 5 tests: return ((void *)0) ; Executed by:
| 2579 | ||||||||||||||||||||||||
192 | } | - | ||||||||||||||||||||||||
193 | void * | - | ||||||||||||||||||||||||
194 | hash_get_first (const Hash_table *table) | - | ||||||||||||||||||||||||
195 | { | - | ||||||||||||||||||||||||
196 | struct hash_entry const *bucket; | - | ||||||||||||||||||||||||
197 | - | |||||||||||||||||||||||||
198 | if (table->n_entries == 0
| 0 | ||||||||||||||||||||||||
199 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
200 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
201 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
202 | - | |||||||||||||||||||||||||
203 | for (bucket = table->bucket; ; bucket++) | - | ||||||||||||||||||||||||
204 | if (! (bucket < table->bucket_limit)
| 0 | ||||||||||||||||||||||||
205 | abort (); never executed: abort (); | 0 | ||||||||||||||||||||||||
206 | else if (bucket->data
| 0 | ||||||||||||||||||||||||
207 | return never executed: bucket->data;return bucket->data; never executed: return bucket->data; | 0 | ||||||||||||||||||||||||
208 | } never executed: end of block | 0 | ||||||||||||||||||||||||
209 | - | |||||||||||||||||||||||||
210 | - | |||||||||||||||||||||||||
211 | - | |||||||||||||||||||||||||
212 | - | |||||||||||||||||||||||||
213 | - | |||||||||||||||||||||||||
214 | void * | - | ||||||||||||||||||||||||
215 | hash_get_next (const Hash_table *table, const void *entry) | - | ||||||||||||||||||||||||
216 | { | - | ||||||||||||||||||||||||
217 | struct hash_entry const *bucket = safe_hasher (table, entry); | - | ||||||||||||||||||||||||
218 | struct hash_entry const *cursor; | - | ||||||||||||||||||||||||
219 | - | |||||||||||||||||||||||||
220 | - | |||||||||||||||||||||||||
221 | cursor = bucket; | - | ||||||||||||||||||||||||
222 | do | - | ||||||||||||||||||||||||
223 | { | - | ||||||||||||||||||||||||
224 | if (cursor->data == entry
| 0 | ||||||||||||||||||||||||
225 | return never executed: cursor->next->data;return cursor->next->data; never executed: return cursor->next->data; | 0 | ||||||||||||||||||||||||
226 | cursor = cursor->next; | - | ||||||||||||||||||||||||
227 | } never executed: end of block | 0 | ||||||||||||||||||||||||
228 | while (cursor !=
| 0 | ||||||||||||||||||||||||
229 | ((void *)0)
| 0 | ||||||||||||||||||||||||
230 | ); | - | ||||||||||||||||||||||||
231 | - | |||||||||||||||||||||||||
232 | - | |||||||||||||||||||||||||
233 | while (++
| 0 | ||||||||||||||||||||||||
234 | if (bucket->data
| 0 | ||||||||||||||||||||||||
235 | return never executed: bucket->data;return bucket->data; never executed: return bucket->data; | 0 | ||||||||||||||||||||||||
236 | - | |||||||||||||||||||||||||
237 | - | |||||||||||||||||||||||||
238 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
239 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
240 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
241 | } | - | ||||||||||||||||||||||||
242 | - | |||||||||||||||||||||||||
243 | - | |||||||||||||||||||||||||
244 | - | |||||||||||||||||||||||||
245 | - | |||||||||||||||||||||||||
246 | - | |||||||||||||||||||||||||
247 | size_t | - | ||||||||||||||||||||||||
248 | hash_get_entries (const Hash_table *table, void **buffer, | - | ||||||||||||||||||||||||
249 | size_t buffer_size) | - | ||||||||||||||||||||||||
250 | { | - | ||||||||||||||||||||||||
251 | size_t counter = 0; | - | ||||||||||||||||||||||||
252 | struct hash_entry const *bucket; | - | ||||||||||||||||||||||||
253 | struct hash_entry const *cursor; | - | ||||||||||||||||||||||||
254 | - | |||||||||||||||||||||||||
255 | for (bucket = table->bucket; bucket < table->bucket_limit
| 0 | ||||||||||||||||||||||||
256 | { | - | ||||||||||||||||||||||||
257 | if (bucket->data
| 0 | ||||||||||||||||||||||||
258 | { | - | ||||||||||||||||||||||||
259 | for (cursor = bucket; cursor
| 0 | ||||||||||||||||||||||||
260 | { | - | ||||||||||||||||||||||||
261 | if (counter >= buffer_size
| 0 | ||||||||||||||||||||||||
262 | return never executed: counter;return counter; never executed: return counter; | 0 | ||||||||||||||||||||||||
263 | buffer[counter++] = cursor->data; | - | ||||||||||||||||||||||||
264 | } never executed: end of block | 0 | ||||||||||||||||||||||||
265 | } never executed: end of block | 0 | ||||||||||||||||||||||||
266 | } never executed: end of block | 0 | ||||||||||||||||||||||||
267 | - | |||||||||||||||||||||||||
268 | return never executed: counter;return counter; never executed: return counter; | 0 | ||||||||||||||||||||||||
269 | } | - | ||||||||||||||||||||||||
270 | size_t | - | ||||||||||||||||||||||||
271 | hash_do_for_each (const Hash_table *table, Hash_processor processor, | - | ||||||||||||||||||||||||
272 | void *processor_data) | - | ||||||||||||||||||||||||
273 | { | - | ||||||||||||||||||||||||
274 | size_t counter = 0; | - | ||||||||||||||||||||||||
275 | struct hash_entry const *bucket; | - | ||||||||||||||||||||||||
276 | struct hash_entry const *cursor; | - | ||||||||||||||||||||||||
277 | - | |||||||||||||||||||||||||
278 | for (bucket = table->bucket; bucket < table->bucket_limit
| 0 | ||||||||||||||||||||||||
279 | { | - | ||||||||||||||||||||||||
280 | if (bucket->data
| 0 | ||||||||||||||||||||||||
281 | { | - | ||||||||||||||||||||||||
282 | for (cursor = bucket; cursor
| 0 | ||||||||||||||||||||||||
283 | { | - | ||||||||||||||||||||||||
284 | if (! processor (cursor->data, processor_data)
| 0 | ||||||||||||||||||||||||
285 | return never executed: counter;return counter; never executed: return counter; | 0 | ||||||||||||||||||||||||
286 | counter++; | - | ||||||||||||||||||||||||
287 | } never executed: end of block | 0 | ||||||||||||||||||||||||
288 | } never executed: end of block | 0 | ||||||||||||||||||||||||
289 | } never executed: end of block | 0 | ||||||||||||||||||||||||
290 | - | |||||||||||||||||||||||||
291 | return never executed: counter;return counter; never executed: return counter; | 0 | ||||||||||||||||||||||||
292 | } | - | ||||||||||||||||||||||||
293 | size_t | - | ||||||||||||||||||||||||
294 | hash_string (const char *string, size_t n_buckets) | - | ||||||||||||||||||||||||
295 | { | - | ||||||||||||||||||||||||
296 | size_t value = 0; | - | ||||||||||||||||||||||||
297 | unsigned char ch; | - | ||||||||||||||||||||||||
298 | - | |||||||||||||||||||||||||
299 | for (; (
| 90-307 | ||||||||||||||||||||||||
300 | value = (value * 31 + ch) % n_buckets; executed 307 times by 1 test: value = (value * 31 + ch) % n_buckets; Executed by:
| 307 | ||||||||||||||||||||||||
301 | return executed 90 times by 1 test: value;return value; Executed by:
executed 90 times by 1 test: return value; Executed by:
| 90 | ||||||||||||||||||||||||
302 | } | - | ||||||||||||||||||||||||
303 | - | |||||||||||||||||||||||||
304 | - | |||||||||||||||||||||||||
305 | - | |||||||||||||||||||||||||
306 | - | |||||||||||||||||||||||||
307 | - | |||||||||||||||||||||||||
308 | - | |||||||||||||||||||||||||
309 | static | - | ||||||||||||||||||||||||
310 | _Bool | - | ||||||||||||||||||||||||
311 | __attribute__ ((__const__)) | - | ||||||||||||||||||||||||
312 | is_prime (size_t candidate) | - | ||||||||||||||||||||||||
313 | { | - | ||||||||||||||||||||||||
314 | size_t divisor = 3; | - | ||||||||||||||||||||||||
315 | size_t square = divisor * divisor; | - | ||||||||||||||||||||||||
316 | - | |||||||||||||||||||||||||
317 | while (square < candidate
| 2023-15862 | ||||||||||||||||||||||||
318 | { | - | ||||||||||||||||||||||||
319 | divisor++; | - | ||||||||||||||||||||||||
320 | square += 4 * divisor; | - | ||||||||||||||||||||||||
321 | divisor++; | - | ||||||||||||||||||||||||
322 | } executed 13839 times by 16 tests: end of block Executed by:
| 13839 | ||||||||||||||||||||||||
323 | - | |||||||||||||||||||||||||
324 | return executed 8777 times by 16 tests: (candidate % divisor ? return (candidate % divisor ? 1 : 0 ); Executed by:
executed 8777 times by 16 tests: return (candidate % divisor ? 1 : 0 ); Executed by:
| 8777 | ||||||||||||||||||||||||
325 | 1 executed 8777 times by 16 tests: return (candidate % divisor ? 1 : 0 ); Executed by:
| 8777 | ||||||||||||||||||||||||
326 | : executed 8777 times by 16 tests: return (candidate % divisor ? 1 : 0 ); Executed by:
| 8777 | ||||||||||||||||||||||||
327 | 0 executed 8777 times by 16 tests: return (candidate % divisor ? 1 : 0 ); Executed by:
| 8777 | ||||||||||||||||||||||||
328 | ); executed 8777 times by 16 tests: return (candidate % divisor ? 1 : 0 ); Executed by:
| 8777 | ||||||||||||||||||||||||
329 | } | - | ||||||||||||||||||||||||
330 | - | |||||||||||||||||||||||||
331 | - | |||||||||||||||||||||||||
332 | - | |||||||||||||||||||||||||
333 | - | |||||||||||||||||||||||||
334 | static size_t __attribute__ ((__const__)) | - | ||||||||||||||||||||||||
335 | next_prime (size_t candidate) | - | ||||||||||||||||||||||||
336 | { | - | ||||||||||||||||||||||||
337 | - | |||||||||||||||||||||||||
338 | if (candidate < 10
| 215-6539 | ||||||||||||||||||||||||
339 | candidate = 10; executed 215 times by 6 tests: candidate = 10; Executed by:
| 215 | ||||||||||||||||||||||||
340 | - | |||||||||||||||||||||||||
341 | - | |||||||||||||||||||||||||
342 | candidate |= 1; | - | ||||||||||||||||||||||||
343 | - | |||||||||||||||||||||||||
344 | while ( | - | ||||||||||||||||||||||||
345 | (
| 0-8777 | ||||||||||||||||||||||||
346 | != candidate
| 0-8777 | ||||||||||||||||||||||||
347 | candidate += 2; executed 2023 times by 9 tests: candidate += 2; Executed by:
| 2023 | ||||||||||||||||||||||||
348 | - | |||||||||||||||||||||||||
349 | return executed 6754 times by 16 tests: candidate;return candidate; Executed by:
executed 6754 times by 16 tests: return candidate; Executed by:
| 6754 | ||||||||||||||||||||||||
350 | } | - | ||||||||||||||||||||||||
351 | - | |||||||||||||||||||||||||
352 | void | - | ||||||||||||||||||||||||
353 | hash_reset_tuning (Hash_tuning *tuning) | - | ||||||||||||||||||||||||
354 | { | - | ||||||||||||||||||||||||
355 | *tuning = default_tuning; | - | ||||||||||||||||||||||||
356 | } never executed: end of block | 0 | ||||||||||||||||||||||||
357 | - | |||||||||||||||||||||||||
358 | - | |||||||||||||||||||||||||
359 | static size_t | - | ||||||||||||||||||||||||
360 | raw_hasher (const void *data, size_t n) | - | ||||||||||||||||||||||||
361 | { | - | ||||||||||||||||||||||||
362 | - | |||||||||||||||||||||||||
363 | - | |||||||||||||||||||||||||
364 | - | |||||||||||||||||||||||||
365 | - | |||||||||||||||||||||||||
366 | - | |||||||||||||||||||||||||
367 | size_t val = rotr_sz ((size_t) data, 3); | - | ||||||||||||||||||||||||
368 | return never executed: val % n;return val % n; never executed: return val % n; | 0 | ||||||||||||||||||||||||
369 | } | - | ||||||||||||||||||||||||
370 | - | |||||||||||||||||||||||||
371 | - | |||||||||||||||||||||||||
372 | static | - | ||||||||||||||||||||||||
373 | _Bool | - | ||||||||||||||||||||||||
374 | - | |||||||||||||||||||||||||
375 | raw_comparator (const void *a, const void *b) | - | ||||||||||||||||||||||||
376 | { | - | ||||||||||||||||||||||||
377 | return executed 316 times by 1 test: a == b;return a == b; Executed by:
executed 316 times by 1 test: return a == b; Executed by:
| 316 | ||||||||||||||||||||||||
378 | } | - | ||||||||||||||||||||||||
379 | static | - | ||||||||||||||||||||||||
380 | _Bool | - | ||||||||||||||||||||||||
381 | - | |||||||||||||||||||||||||
382 | check_tuning (Hash_table *table) | - | ||||||||||||||||||||||||
383 | { | - | ||||||||||||||||||||||||
384 | const Hash_tuning *tuning = table->tuning; | - | ||||||||||||||||||||||||
385 | float epsilon; | - | ||||||||||||||||||||||||
386 | if (tuning == &default_tuning
| 0-6754 | ||||||||||||||||||||||||
387 | return executed 6754 times by 16 tests: return 1 ; Executed by:
executed 6754 times by 16 tests: return 1 ; Executed by:
| 6754 | ||||||||||||||||||||||||
388 | 1 executed 6754 times by 16 tests: return 1 ; Executed by:
| 6754 | ||||||||||||||||||||||||
389 | ; executed 6754 times by 16 tests: return 1 ; Executed by:
| 6754 | ||||||||||||||||||||||||
390 | - | |||||||||||||||||||||||||
391 | - | |||||||||||||||||||||||||
392 | - | |||||||||||||||||||||||||
393 | - | |||||||||||||||||||||||||
394 | - | |||||||||||||||||||||||||
395 | - | |||||||||||||||||||||||||
396 | epsilon = 0.1f; | - | ||||||||||||||||||||||||
397 | - | |||||||||||||||||||||||||
398 | if (epsilon < tuning->growth_threshold
| 0 | ||||||||||||||||||||||||
399 | && tuning->growth_threshold < 1 - epsilon
| 0 | ||||||||||||||||||||||||
400 | && 1 + epsilon < tuning->growth_factor
| 0 | ||||||||||||||||||||||||
401 | && 0 <= tuning->shrink_threshold
| 0 | ||||||||||||||||||||||||
402 | && tuning->shrink_threshold + epsilon < tuning->shrink_factor
| 0 | ||||||||||||||||||||||||
403 | && tuning->shrink_factor <= 1
| 0 | ||||||||||||||||||||||||
404 | && tuning->shrink_threshold + epsilon < tuning->growth_threshold
| 0 | ||||||||||||||||||||||||
405 | return never executed: return 1 ; never executed: return 1 ; | 0 | ||||||||||||||||||||||||
406 | 1 never executed: return 1 ; | 0 | ||||||||||||||||||||||||
407 | ; never executed: return 1 ; | 0 | ||||||||||||||||||||||||
408 | - | |||||||||||||||||||||||||
409 | table->tuning = &default_tuning; | - | ||||||||||||||||||||||||
410 | return never executed: return 0 ; never executed: return 0 ; | 0 | ||||||||||||||||||||||||
411 | 0 never executed: return 0 ; | 0 | ||||||||||||||||||||||||
412 | ; never executed: return 0 ; | 0 | ||||||||||||||||||||||||
413 | } | - | ||||||||||||||||||||||||
414 | - | |||||||||||||||||||||||||
415 | - | |||||||||||||||||||||||||
416 | - | |||||||||||||||||||||||||
417 | - | |||||||||||||||||||||||||
418 | - | |||||||||||||||||||||||||
419 | static size_t | - | ||||||||||||||||||||||||
420 | __attribute__ ((__pure__)) | - | ||||||||||||||||||||||||
421 | - | |||||||||||||||||||||||||
422 | compute_bucket_size (size_t candidate, const Hash_tuning *tuning) | - | ||||||||||||||||||||||||
423 | { | - | ||||||||||||||||||||||||
424 | if (!tuning->is_n_buckets
| 0-6754 | ||||||||||||||||||||||||
425 | { | - | ||||||||||||||||||||||||
426 | float new_candidate = candidate / tuning->growth_threshold; | - | ||||||||||||||||||||||||
427 | if ( | - | ||||||||||||||||||||||||
428 | (
| 0-6754 | ||||||||||||||||||||||||
429 | <= new_candidate
| 0-6754 | ||||||||||||||||||||||||
430 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
431 | candidate = new_candidate; | - | ||||||||||||||||||||||||
432 | } executed 6754 times by 16 tests: end of block Executed by:
| 6754 | ||||||||||||||||||||||||
433 | candidate = next_prime (candidate); | - | ||||||||||||||||||||||||
434 | if ((
| 0-6754 | ||||||||||||||||||||||||
435 | (9223372036854775807L)
| 0-6754 | ||||||||||||||||||||||||
436 | <
| 0-6754 | ||||||||||||||||||||||||
437 | (18446744073709551615UL)
| 0-6754 | ||||||||||||||||||||||||
438 | ?
| 0-6754 | ||||||||||||||||||||||||
439 | (9223372036854775807L)
| 0-6754 | ||||||||||||||||||||||||
440 | :
| 0-6754 | ||||||||||||||||||||||||
441 | (18446744073709551615UL)
| 0-6754 | ||||||||||||||||||||||||
442 | - 1) / (sizeof (struct hash_entry *)) < (candidate)) : ({ __xalloc_count_type __xalloc_count; __builtin_mul_overflow (candidate, sizeof (struct hash_entry *), &__xalloc_count); }))
| 0-6754 | ||||||||||||||||||||||||
443 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
444 | return executed 6754 times by 16 tests: candidate;return candidate; Executed by:
executed 6754 times by 16 tests: return candidate; Executed by:
| 6754 | ||||||||||||||||||||||||
445 | } | - | ||||||||||||||||||||||||
446 | Hash_table * | - | ||||||||||||||||||||||||
447 | hash_initialize (size_t candidate, const Hash_tuning *tuning, | - | ||||||||||||||||||||||||
448 | Hash_hasher hasher, Hash_comparator comparator, | - | ||||||||||||||||||||||||
449 | Hash_data_freer data_freer) | - | ||||||||||||||||||||||||
450 | { | - | ||||||||||||||||||||||||
451 | Hash_table *table; | - | ||||||||||||||||||||||||
452 | - | |||||||||||||||||||||||||
453 | if (hasher ==
| 0-6728 | ||||||||||||||||||||||||
454 | ((void *)0)
| 0-6728 | ||||||||||||||||||||||||
455 | ) | - | ||||||||||||||||||||||||
456 | hasher = raw_hasher; never executed: hasher = raw_hasher; | 0 | ||||||||||||||||||||||||
457 | if (comparator ==
| 27-6701 | ||||||||||||||||||||||||
458 | ((void *)0)
| 27-6701 | ||||||||||||||||||||||||
459 | ) | - | ||||||||||||||||||||||||
460 | comparator = raw_comparator; executed 27 times by 1 test: comparator = raw_comparator; Executed by:
| 27 | ||||||||||||||||||||||||
461 | - | |||||||||||||||||||||||||
462 | table = malloc (sizeof *table); | - | ||||||||||||||||||||||||
463 | if (table ==
| 0-6728 | ||||||||||||||||||||||||
464 | ((void *)0)
| 0-6728 | ||||||||||||||||||||||||
465 | ) | - | ||||||||||||||||||||||||
466 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
467 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
468 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
469 | - | |||||||||||||||||||||||||
470 | if (!tuning
| 0-6728 | ||||||||||||||||||||||||
471 | tuning = &default_tuning; executed 6728 times by 16 tests: tuning = &default_tuning; Executed by:
| 6728 | ||||||||||||||||||||||||
472 | table->tuning = tuning; | - | ||||||||||||||||||||||||
473 | if (!check_tuning (table)
| 0-6728 | ||||||||||||||||||||||||
474 | { | - | ||||||||||||||||||||||||
475 | - | |||||||||||||||||||||||||
476 | - | |||||||||||||||||||||||||
477 | - | |||||||||||||||||||||||||
478 | - | |||||||||||||||||||||||||
479 | - | |||||||||||||||||||||||||
480 | goto never executed: fail;goto fail; never executed: goto fail; | 0 | ||||||||||||||||||||||||
481 | } | - | ||||||||||||||||||||||||
482 | - | |||||||||||||||||||||||||
483 | table->n_buckets = compute_bucket_size (candidate, tuning); | - | ||||||||||||||||||||||||
484 | if (!table->n_buckets
| 0-6728 | ||||||||||||||||||||||||
485 | goto never executed: fail;goto fail; never executed: goto fail; | 0 | ||||||||||||||||||||||||
486 | - | |||||||||||||||||||||||||
487 | table->bucket = calloc (table->n_buckets, sizeof *table->bucket); | - | ||||||||||||||||||||||||
488 | if (table->bucket ==
| 0-6728 | ||||||||||||||||||||||||
489 | ((void *)0)
| 0-6728 | ||||||||||||||||||||||||
490 | ) | - | ||||||||||||||||||||||||
491 | goto never executed: fail;goto fail; never executed: goto fail; | 0 | ||||||||||||||||||||||||
492 | table->bucket_limit = table->bucket + table->n_buckets; | - | ||||||||||||||||||||||||
493 | table->n_buckets_used = 0; | - | ||||||||||||||||||||||||
494 | table->n_entries = 0; | - | ||||||||||||||||||||||||
495 | - | |||||||||||||||||||||||||
496 | table->hasher = hasher; | - | ||||||||||||||||||||||||
497 | table->comparator = comparator; | - | ||||||||||||||||||||||||
498 | table->data_freer = data_freer; | - | ||||||||||||||||||||||||
499 | - | |||||||||||||||||||||||||
500 | table->free_entry_list = | - | ||||||||||||||||||||||||
501 | ((void *)0) | - | ||||||||||||||||||||||||
502 | ; | - | ||||||||||||||||||||||||
503 | - | |||||||||||||||||||||||||
504 | - | |||||||||||||||||||||||||
505 | - | |||||||||||||||||||||||||
506 | return executed 6728 times by 16 tests: table;return table; Executed by:
executed 6728 times by 16 tests: return table; Executed by:
| 6728 | ||||||||||||||||||||||||
507 | - | |||||||||||||||||||||||||
508 | fail: | - | ||||||||||||||||||||||||
509 | free (table); | - | ||||||||||||||||||||||||
510 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
511 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
512 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
513 | } | - | ||||||||||||||||||||||||
514 | - | |||||||||||||||||||||||||
515 | - | |||||||||||||||||||||||||
516 | - | |||||||||||||||||||||||||
517 | - | |||||||||||||||||||||||||
518 | - | |||||||||||||||||||||||||
519 | void | - | ||||||||||||||||||||||||
520 | hash_clear (Hash_table *table) | - | ||||||||||||||||||||||||
521 | { | - | ||||||||||||||||||||||||
522 | struct hash_entry *bucket; | - | ||||||||||||||||||||||||
523 | - | |||||||||||||||||||||||||
524 | for (bucket = table->bucket; bucket < table->bucket_limit
| 0 | ||||||||||||||||||||||||
525 | { | - | ||||||||||||||||||||||||
526 | if (bucket->data
| 0 | ||||||||||||||||||||||||
527 | { | - | ||||||||||||||||||||||||
528 | struct hash_entry *cursor; | - | ||||||||||||||||||||||||
529 | struct hash_entry *next; | - | ||||||||||||||||||||||||
530 | - | |||||||||||||||||||||||||
531 | - | |||||||||||||||||||||||||
532 | for (cursor = bucket->next; cursor
| 0 | ||||||||||||||||||||||||
533 | { | - | ||||||||||||||||||||||||
534 | if (table->data_freer
| 0 | ||||||||||||||||||||||||
535 | table->data_freer (cursor->data); never executed: table->data_freer (cursor->data); | 0 | ||||||||||||||||||||||||
536 | cursor->data = | - | ||||||||||||||||||||||||
537 | ((void *)0) | - | ||||||||||||||||||||||||
538 | ; | - | ||||||||||||||||||||||||
539 | - | |||||||||||||||||||||||||
540 | next = cursor->next; | - | ||||||||||||||||||||||||
541 | - | |||||||||||||||||||||||||
542 | - | |||||||||||||||||||||||||
543 | cursor->next = table->free_entry_list; | - | ||||||||||||||||||||||||
544 | table->free_entry_list = cursor; | - | ||||||||||||||||||||||||
545 | } never executed: end of block | 0 | ||||||||||||||||||||||||
546 | - | |||||||||||||||||||||||||
547 | - | |||||||||||||||||||||||||
548 | if (table->data_freer
| 0 | ||||||||||||||||||||||||
549 | table->data_freer (bucket->data); never executed: table->data_freer (bucket->data); | 0 | ||||||||||||||||||||||||
550 | bucket->data = | - | ||||||||||||||||||||||||
551 | ((void *)0) | - | ||||||||||||||||||||||||
552 | ; | - | ||||||||||||||||||||||||
553 | bucket->next = | - | ||||||||||||||||||||||||
554 | ((void *)0) | - | ||||||||||||||||||||||||
555 | ; | - | ||||||||||||||||||||||||
556 | } never executed: end of block | 0 | ||||||||||||||||||||||||
557 | } never executed: end of block | 0 | ||||||||||||||||||||||||
558 | - | |||||||||||||||||||||||||
559 | table->n_buckets_used = 0; | - | ||||||||||||||||||||||||
560 | table->n_entries = 0; | - | ||||||||||||||||||||||||
561 | } never executed: end of block | 0 | ||||||||||||||||||||||||
562 | - | |||||||||||||||||||||||||
563 | - | |||||||||||||||||||||||||
564 | - | |||||||||||||||||||||||||
565 | - | |||||||||||||||||||||||||
566 | - | |||||||||||||||||||||||||
567 | - | |||||||||||||||||||||||||
568 | void | - | ||||||||||||||||||||||||
569 | hash_free (Hash_table *table) | - | ||||||||||||||||||||||||
570 | { | - | ||||||||||||||||||||||||
571 | struct hash_entry *bucket; | - | ||||||||||||||||||||||||
572 | struct hash_entry *cursor; | - | ||||||||||||||||||||||||
573 | struct hash_entry *next; | - | ||||||||||||||||||||||||
574 | - | |||||||||||||||||||||||||
575 | - | |||||||||||||||||||||||||
576 | if (table->data_freer
| 28-5207 | ||||||||||||||||||||||||
577 | { | - | ||||||||||||||||||||||||
578 | for (bucket = table->bucket; bucket < table->bucket_limit
| 409-6463 | ||||||||||||||||||||||||
579 | { | - | ||||||||||||||||||||||||
580 | if (bucket->data
| 958-5505 | ||||||||||||||||||||||||
581 | { | - | ||||||||||||||||||||||||
582 | for (cursor = bucket; cursor
| 958-989 | ||||||||||||||||||||||||
583 | table->data_freer (cursor->data); executed 989 times by 9 tests: table->data_freer (cursor->data); Executed by:
| 989 | ||||||||||||||||||||||||
584 | } executed 958 times by 9 tests: end of block Executed by:
| 958 | ||||||||||||||||||||||||
585 | } executed 6463 times by 9 tests: end of block Executed by:
| 6463 | ||||||||||||||||||||||||
586 | } executed 409 times by 9 tests: end of block Executed by:
| 409 | ||||||||||||||||||||||||
587 | for (bucket = table->bucket; bucket < table->bucket_limit
| 5235-134913 | ||||||||||||||||||||||||
588 | { | - | ||||||||||||||||||||||||
589 | for (cursor = bucket->next; cursor
| 347-134913 | ||||||||||||||||||||||||
590 | { | - | ||||||||||||||||||||||||
591 | next = cursor->next; | - | ||||||||||||||||||||||||
592 | free (cursor); | - | ||||||||||||||||||||||||
593 | } executed 347 times by 4 tests: end of block Executed by:
| 347 | ||||||||||||||||||||||||
594 | } executed 134913 times by 13 tests: end of block Executed by:
| 134913 | ||||||||||||||||||||||||
595 | - | |||||||||||||||||||||||||
596 | - | |||||||||||||||||||||||||
597 | for (cursor = table->free_entry_list; cursor
| 14-5235 | ||||||||||||||||||||||||
598 | { | - | ||||||||||||||||||||||||
599 | next = cursor->next; | - | ||||||||||||||||||||||||
600 | free (cursor); | - | ||||||||||||||||||||||||
601 | } executed 14 times by 1 test: end of block Executed by:
| 14 | ||||||||||||||||||||||||
602 | - | |||||||||||||||||||||||||
603 | - | |||||||||||||||||||||||||
604 | - | |||||||||||||||||||||||||
605 | - | |||||||||||||||||||||||||
606 | free (table->bucket); | - | ||||||||||||||||||||||||
607 | free (table); | - | ||||||||||||||||||||||||
608 | } executed 5235 times by 13 tests: end of block Executed by:
| 5235 | ||||||||||||||||||||||||
609 | - | |||||||||||||||||||||||||
610 | - | |||||||||||||||||||||||||
611 | - | |||||||||||||||||||||||||
612 | - | |||||||||||||||||||||||||
613 | - | |||||||||||||||||||||||||
614 | - | |||||||||||||||||||||||||
615 | static struct hash_entry * | - | ||||||||||||||||||||||||
616 | allocate_entry (Hash_table *table) | - | ||||||||||||||||||||||||
617 | { | - | ||||||||||||||||||||||||
618 | struct hash_entry *new; | - | ||||||||||||||||||||||||
619 | - | |||||||||||||||||||||||||
620 | if (table->free_entry_list
| 5610-8454 | ||||||||||||||||||||||||
621 | { | - | ||||||||||||||||||||||||
622 | new = table->free_entry_list; | - | ||||||||||||||||||||||||
623 | table->free_entry_list = new->next; | - | ||||||||||||||||||||||||
624 | } executed 8454 times by 4 tests: end of block Executed by:
| 8454 | ||||||||||||||||||||||||
625 | else | - | ||||||||||||||||||||||||
626 | { | - | ||||||||||||||||||||||||
627 | - | |||||||||||||||||||||||||
628 | - | |||||||||||||||||||||||||
629 | - | |||||||||||||||||||||||||
630 | new = malloc (sizeof *new); | - | ||||||||||||||||||||||||
631 | - | |||||||||||||||||||||||||
632 | } executed 5610 times by 7 tests: end of block Executed by:
| 5610 | ||||||||||||||||||||||||
633 | - | |||||||||||||||||||||||||
634 | return executed 14064 times by 7 tests: new;return new; Executed by:
executed 14064 times by 7 tests: return new; Executed by:
| 14064 | ||||||||||||||||||||||||
635 | } | - | ||||||||||||||||||||||||
636 | - | |||||||||||||||||||||||||
637 | - | |||||||||||||||||||||||||
638 | - | |||||||||||||||||||||||||
639 | - | |||||||||||||||||||||||||
640 | static void | - | ||||||||||||||||||||||||
641 | free_entry (Hash_table *table, struct hash_entry *entry) | - | ||||||||||||||||||||||||
642 | { | - | ||||||||||||||||||||||||
643 | entry->data = | - | ||||||||||||||||||||||||
644 | ((void *)0) | - | ||||||||||||||||||||||||
645 | ; | - | ||||||||||||||||||||||||
646 | entry->next = table->free_entry_list; | - | ||||||||||||||||||||||||
647 | table->free_entry_list = entry; | - | ||||||||||||||||||||||||
648 | } executed 8805 times by 4 tests: end of block Executed by:
| 8805 | ||||||||||||||||||||||||
649 | - | |||||||||||||||||||||||||
650 | - | |||||||||||||||||||||||||
651 | - | |||||||||||||||||||||||||
652 | - | |||||||||||||||||||||||||
653 | - | |||||||||||||||||||||||||
654 | - | |||||||||||||||||||||||||
655 | - | |||||||||||||||||||||||||
656 | static void * | - | ||||||||||||||||||||||||
657 | hash_find_entry (Hash_table *table, const void *entry, | - | ||||||||||||||||||||||||
658 | struct hash_entry **bucket_head, | - | ||||||||||||||||||||||||
659 | _Bool | - | ||||||||||||||||||||||||
660 | delete) | - | ||||||||||||||||||||||||
661 | { | - | ||||||||||||||||||||||||
662 | struct hash_entry *bucket = safe_hasher (table, entry); | - | ||||||||||||||||||||||||
663 | struct hash_entry *cursor; | - | ||||||||||||||||||||||||
664 | - | |||||||||||||||||||||||||
665 | *bucket_head = bucket; | - | ||||||||||||||||||||||||
666 | - | |||||||||||||||||||||||||
667 | - | |||||||||||||||||||||||||
668 | if (bucket->data ==
| 13077-13675 | ||||||||||||||||||||||||
669 | ((void *)0)
| 13077-13675 | ||||||||||||||||||||||||
670 | ) | - | ||||||||||||||||||||||||
671 | return executed 13077 times by 16 tests: return ((void *)0) ; Executed by:
executed 13077 times by 16 tests: return ((void *)0) ; Executed by:
| 13077 | ||||||||||||||||||||||||
672 | ((void *)0) executed 13077 times by 16 tests: return ((void *)0) ; Executed by:
| 13077 | ||||||||||||||||||||||||
673 | ; executed 13077 times by 16 tests: return ((void *)0) ; Executed by:
| 13077 | ||||||||||||||||||||||||
674 | - | |||||||||||||||||||||||||
675 | - | |||||||||||||||||||||||||
676 | if (entry == bucket->data
| 274-13401 | ||||||||||||||||||||||||
677 | { | - | ||||||||||||||||||||||||
678 | void *data = bucket->data; | - | ||||||||||||||||||||||||
679 | - | |||||||||||||||||||||||||
680 | if (delete
| 78-5305 | ||||||||||||||||||||||||
681 | { | - | ||||||||||||||||||||||||
682 | if (bucket->next
| 141-5164 | ||||||||||||||||||||||||
683 | { | - | ||||||||||||||||||||||||
684 | struct hash_entry *next = bucket->next; | - | ||||||||||||||||||||||||
685 | - | |||||||||||||||||||||||||
686 | - | |||||||||||||||||||||||||
687 | - | |||||||||||||||||||||||||
688 | *bucket = *next; | - | ||||||||||||||||||||||||
689 | free_entry (table, next); | - | ||||||||||||||||||||||||
690 | } executed 141 times by 2 tests: end of block Executed by:
| 141 | ||||||||||||||||||||||||
691 | else | - | ||||||||||||||||||||||||
692 | { | - | ||||||||||||||||||||||||
693 | bucket->data = | - | ||||||||||||||||||||||||
694 | ((void *)0) | - | ||||||||||||||||||||||||
695 | ; | - | ||||||||||||||||||||||||
696 | } executed 5164 times by 7 tests: end of block Executed by:
| 5164 | ||||||||||||||||||||||||
697 | } | - | ||||||||||||||||||||||||
698 | - | |||||||||||||||||||||||||
699 | return executed 5383 times by 9 tests: data;return data; Executed by:
executed 5383 times by 9 tests: return data; Executed by:
| 5383 | ||||||||||||||||||||||||
700 | } | - | ||||||||||||||||||||||||
701 | - | |||||||||||||||||||||||||
702 | - | |||||||||||||||||||||||||
703 | for (cursor = bucket; cursor->next
| 5237-8221 | ||||||||||||||||||||||||
704 | { | - | ||||||||||||||||||||||||
705 | if (entry == cursor->next->data
| 0-5237 | ||||||||||||||||||||||||
706 | || table->comparator (entry, cursor->next->data)
| 71-5166 | ||||||||||||||||||||||||
707 | { | - | ||||||||||||||||||||||||
708 | void *data = cursor->next->data; | - | ||||||||||||||||||||||||
709 | - | |||||||||||||||||||||||||
710 | if (delete
| 0-71 | ||||||||||||||||||||||||
711 | { | - | ||||||||||||||||||||||||
712 | struct hash_entry *next = cursor->next; | - | ||||||||||||||||||||||||
713 | - | |||||||||||||||||||||||||
714 | - | |||||||||||||||||||||||||
715 | - | |||||||||||||||||||||||||
716 | cursor->next = next->next; | - | ||||||||||||||||||||||||
717 | free_entry (table, next); | - | ||||||||||||||||||||||||
718 | } executed 71 times by 2 tests: end of block Executed by:
| 71 | ||||||||||||||||||||||||
719 | - | |||||||||||||||||||||||||
720 | return executed 71 times by 2 tests: data;return data; Executed by:
executed 71 times by 2 tests: return data; Executed by:
| 71 | ||||||||||||||||||||||||
721 | } | - | ||||||||||||||||||||||||
722 | } executed 5166 times by 4 tests: end of block Executed by:
| 5166 | ||||||||||||||||||||||||
723 | - | |||||||||||||||||||||||||
724 | - | |||||||||||||||||||||||||
725 | return executed 8221 times by 7 tests: return ((void *)0) ; Executed by:
executed 8221 times by 7 tests: return ((void *)0) ; Executed by:
| 8221 | ||||||||||||||||||||||||
726 | ((void *)0) executed 8221 times by 7 tests: return ((void *)0) ; Executed by:
| 8221 | ||||||||||||||||||||||||
727 | ; executed 8221 times by 7 tests: return ((void *)0) ; Executed by:
| 8221 | ||||||||||||||||||||||||
728 | } | - | ||||||||||||||||||||||||
729 | - | |||||||||||||||||||||||||
730 | - | |||||||||||||||||||||||||
731 | - | |||||||||||||||||||||||||
732 | - | |||||||||||||||||||||||||
733 | - | |||||||||||||||||||||||||
734 | - | |||||||||||||||||||||||||
735 | - | |||||||||||||||||||||||||
736 | static | - | ||||||||||||||||||||||||
737 | _Bool | - | ||||||||||||||||||||||||
738 | - | |||||||||||||||||||||||||
739 | transfer_entries (Hash_table *dst, Hash_table *src, | - | ||||||||||||||||||||||||
740 | _Bool | - | ||||||||||||||||||||||||
741 | safe) | - | ||||||||||||||||||||||||
742 | { | - | ||||||||||||||||||||||||
743 | struct hash_entry *bucket; | - | ||||||||||||||||||||||||
744 | struct hash_entry *cursor; | - | ||||||||||||||||||||||||
745 | struct hash_entry *next; | - | ||||||||||||||||||||||||
746 | for (bucket = src->bucket; bucket < src->bucket_limit
| 26-24874 | ||||||||||||||||||||||||
747 | if (bucket->data
| 4964-19910 | ||||||||||||||||||||||||
748 | { | - | ||||||||||||||||||||||||
749 | void *data; | - | ||||||||||||||||||||||||
750 | struct hash_entry *new_bucket; | - | ||||||||||||||||||||||||
751 | - | |||||||||||||||||||||||||
752 | - | |||||||||||||||||||||||||
753 | - | |||||||||||||||||||||||||
754 | - | |||||||||||||||||||||||||
755 | - | |||||||||||||||||||||||||
756 | - | |||||||||||||||||||||||||
757 | - | |||||||||||||||||||||||||
758 | for (cursor = bucket->next; cursor
| 12706-19910 | ||||||||||||||||||||||||
759 | { | - | ||||||||||||||||||||||||
760 | data = cursor->data; | - | ||||||||||||||||||||||||
761 | new_bucket = safe_hasher (dst, data); | - | ||||||||||||||||||||||||
762 | - | |||||||||||||||||||||||||
763 | next = cursor->next; | - | ||||||||||||||||||||||||
764 | - | |||||||||||||||||||||||||
765 | if (new_bucket->data
| 4113-8593 | ||||||||||||||||||||||||
766 | { | - | ||||||||||||||||||||||||
767 | - | |||||||||||||||||||||||||
768 | - | |||||||||||||||||||||||||
769 | cursor->next = new_bucket->next; | - | ||||||||||||||||||||||||
770 | new_bucket->next = cursor; | - | ||||||||||||||||||||||||
771 | } executed 4113 times by 3 tests: end of block Executed by:
| 4113 | ||||||||||||||||||||||||
772 | else | - | ||||||||||||||||||||||||
773 | { | - | ||||||||||||||||||||||||
774 | - | |||||||||||||||||||||||||
775 | - | |||||||||||||||||||||||||
776 | new_bucket->data = data; | - | ||||||||||||||||||||||||
777 | dst->n_buckets_used++; | - | ||||||||||||||||||||||||
778 | free_entry (dst, cursor); | - | ||||||||||||||||||||||||
779 | } executed 8593 times by 3 tests: end of block Executed by:
| 8593 | ||||||||||||||||||||||||
780 | } | - | ||||||||||||||||||||||||
781 | - | |||||||||||||||||||||||||
782 | - | |||||||||||||||||||||||||
783 | - | |||||||||||||||||||||||||
784 | data = bucket->data; | - | ||||||||||||||||||||||||
785 | bucket->next = | - | ||||||||||||||||||||||||
786 | ((void *)0) | - | ||||||||||||||||||||||||
787 | ; | - | ||||||||||||||||||||||||
788 | if (safe
| 0-19910 | ||||||||||||||||||||||||
789 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
790 | new_bucket = safe_hasher (dst, data); | - | ||||||||||||||||||||||||
791 | - | |||||||||||||||||||||||||
792 | if (new_bucket->data
| 5859-14051 | ||||||||||||||||||||||||
793 | { | - | ||||||||||||||||||||||||
794 | - | |||||||||||||||||||||||||
795 | - | |||||||||||||||||||||||||
796 | struct hash_entry *new_entry = allocate_entry (dst); | - | ||||||||||||||||||||||||
797 | - | |||||||||||||||||||||||||
798 | if (new_entry ==
| 0-5859 | ||||||||||||||||||||||||
799 | ((void *)0)
| 0-5859 | ||||||||||||||||||||||||
800 | ) | - | ||||||||||||||||||||||||
801 | return never executed: return 0 ; never executed: return 0 ; | 0 | ||||||||||||||||||||||||
802 | 0 never executed: return 0 ; | 0 | ||||||||||||||||||||||||
803 | ; never executed: return 0 ; | 0 | ||||||||||||||||||||||||
804 | - | |||||||||||||||||||||||||
805 | new_entry->data = data; | - | ||||||||||||||||||||||||
806 | new_entry->next = new_bucket->next; | - | ||||||||||||||||||||||||
807 | new_bucket->next = new_entry; | - | ||||||||||||||||||||||||
808 | } executed 5859 times by 3 tests: end of block Executed by:
| 5859 | ||||||||||||||||||||||||
809 | else | - | ||||||||||||||||||||||||
810 | { | - | ||||||||||||||||||||||||
811 | - | |||||||||||||||||||||||||
812 | new_bucket->data = data; | - | ||||||||||||||||||||||||
813 | dst->n_buckets_used++; | - | ||||||||||||||||||||||||
814 | } executed 14051 times by 3 tests: end of block Executed by:
| 14051 | ||||||||||||||||||||||||
815 | bucket->data = | - | ||||||||||||||||||||||||
816 | ((void *)0) | - | ||||||||||||||||||||||||
817 | ; | - | ||||||||||||||||||||||||
818 | src->n_buckets_used--; | - | ||||||||||||||||||||||||
819 | } executed 19910 times by 3 tests: end of block Executed by:
| 19910 | ||||||||||||||||||||||||
820 | return executed 26 times by 3 tests: return 1 ; Executed by:
executed 26 times by 3 tests: return 1 ; Executed by:
| 26 | ||||||||||||||||||||||||
821 | 1 executed 26 times by 3 tests: return 1 ; Executed by:
| 26 | ||||||||||||||||||||||||
822 | ; executed 26 times by 3 tests: return 1 ; Executed by:
| 26 | ||||||||||||||||||||||||
823 | } | - | ||||||||||||||||||||||||
824 | - | |||||||||||||||||||||||||
825 | _Bool | - | ||||||||||||||||||||||||
826 | - | |||||||||||||||||||||||||
827 | hash_rehash (Hash_table *table, size_t candidate) | - | ||||||||||||||||||||||||
828 | { | - | ||||||||||||||||||||||||
829 | Hash_table storage; | - | ||||||||||||||||||||||||
830 | Hash_table *new_table; | - | ||||||||||||||||||||||||
831 | size_t new_size = compute_bucket_size (candidate, table->tuning); | - | ||||||||||||||||||||||||
832 | - | |||||||||||||||||||||||||
833 | if (!new_size
| 0-26 | ||||||||||||||||||||||||
834 | return never executed: return 0 ; never executed: return 0 ; | 0 | ||||||||||||||||||||||||
835 | 0 never executed: return 0 ; | 0 | ||||||||||||||||||||||||
836 | ; never executed: return 0 ; | 0 | ||||||||||||||||||||||||
837 | if (new_size == table->n_buckets
| 0-26 | ||||||||||||||||||||||||
838 | return never executed: return 1 ; never executed: return 1 ; | 0 | ||||||||||||||||||||||||
839 | 1 never executed: return 1 ; | 0 | ||||||||||||||||||||||||
840 | ; never executed: return 1 ; | 0 | ||||||||||||||||||||||||
841 | new_table = &storage; | - | ||||||||||||||||||||||||
842 | new_table->bucket = calloc (new_size, sizeof *new_table->bucket); | - | ||||||||||||||||||||||||
843 | if (new_table->bucket ==
| 0-26 | ||||||||||||||||||||||||
844 | ((void *)0)
| 0-26 | ||||||||||||||||||||||||
845 | ) | - | ||||||||||||||||||||||||
846 | return never executed: return 0 ; never executed: return 0 ; | 0 | ||||||||||||||||||||||||
847 | 0 never executed: return 0 ; | 0 | ||||||||||||||||||||||||
848 | ; never executed: return 0 ; | 0 | ||||||||||||||||||||||||
849 | new_table->n_buckets = new_size; | - | ||||||||||||||||||||||||
850 | new_table->bucket_limit = new_table->bucket + new_size; | - | ||||||||||||||||||||||||
851 | new_table->n_buckets_used = 0; | - | ||||||||||||||||||||||||
852 | new_table->n_entries = 0; | - | ||||||||||||||||||||||||
853 | new_table->tuning = table->tuning; | - | ||||||||||||||||||||||||
854 | new_table->hasher = table->hasher; | - | ||||||||||||||||||||||||
855 | new_table->comparator = table->comparator; | - | ||||||||||||||||||||||||
856 | new_table->data_freer = table->data_freer; | - | ||||||||||||||||||||||||
857 | new_table->free_entry_list = table->free_entry_list; | - | ||||||||||||||||||||||||
858 | - | |||||||||||||||||||||||||
859 | if (transfer_entries (new_table, table,
| 0-26 | ||||||||||||||||||||||||
860 | 0
| 0-26 | ||||||||||||||||||||||||
861 | )
| 0-26 | ||||||||||||||||||||||||
862 | { | - | ||||||||||||||||||||||||
863 | - | |||||||||||||||||||||||||
864 | free (table->bucket); | - | ||||||||||||||||||||||||
865 | table->bucket = new_table->bucket; | - | ||||||||||||||||||||||||
866 | table->bucket_limit = new_table->bucket_limit; | - | ||||||||||||||||||||||||
867 | table->n_buckets = new_table->n_buckets; | - | ||||||||||||||||||||||||
868 | table->n_buckets_used = new_table->n_buckets_used; | - | ||||||||||||||||||||||||
869 | table->free_entry_list = new_table->free_entry_list; | - | ||||||||||||||||||||||||
870 | - | |||||||||||||||||||||||||
871 | return executed 26 times by 3 tests: return 1 ; Executed by:
executed 26 times by 3 tests: return 1 ; Executed by:
| 26 | ||||||||||||||||||||||||
872 | 1 executed 26 times by 3 tests: return 1 ; Executed by:
| 26 | ||||||||||||||||||||||||
873 | ; executed 26 times by 3 tests: return 1 ; Executed by:
| 26 | ||||||||||||||||||||||||
874 | } | - | ||||||||||||||||||||||||
875 | table->free_entry_list = new_table->free_entry_list; | - | ||||||||||||||||||||||||
876 | if (! (transfer_entries (table, new_table,
| 0 | ||||||||||||||||||||||||
877 | 1
| 0 | ||||||||||||||||||||||||
878 | )
| 0 | ||||||||||||||||||||||||
879 | && transfer_entries (table, new_table,
| 0 | ||||||||||||||||||||||||
880 | 0
| 0 | ||||||||||||||||||||||||
881 | )
| 0 | ||||||||||||||||||||||||
882 | abort (); never executed: abort (); | 0 | ||||||||||||||||||||||||
883 | - | |||||||||||||||||||||||||
884 | free (new_table->bucket); | - | ||||||||||||||||||||||||
885 | return never executed: return 0 ; never executed: return 0 ; | 0 | ||||||||||||||||||||||||
886 | 0 never executed: return 0 ; | 0 | ||||||||||||||||||||||||
887 | ; never executed: return 0 ; | 0 | ||||||||||||||||||||||||
888 | } | - | ||||||||||||||||||||||||
889 | int | - | ||||||||||||||||||||||||
890 | hash_insert_if_absent (Hash_table *table, void const *entry, | - | ||||||||||||||||||||||||
891 | void const **matched_ent) | - | ||||||||||||||||||||||||
892 | { | - | ||||||||||||||||||||||||
893 | void *data; | - | ||||||||||||||||||||||||
894 | struct hash_entry *bucket; | - | ||||||||||||||||||||||||
895 | - | |||||||||||||||||||||||||
896 | - | |||||||||||||||||||||||||
897 | - | |||||||||||||||||||||||||
898 | - | |||||||||||||||||||||||||
899 | if (! entry
| 0-21080 | ||||||||||||||||||||||||
900 | abort (); never executed: abort (); | 0 | ||||||||||||||||||||||||
901 | - | |||||||||||||||||||||||||
902 | - | |||||||||||||||||||||||||
903 | if ((
| 78-21002 | ||||||||||||||||||||||||
904 | 0
| 78-21002 | ||||||||||||||||||||||||
905 | )) !=
| 78-21002 | ||||||||||||||||||||||||
906 | ((void *)0)
| 78-21002 | ||||||||||||||||||||||||
907 | ) | - | ||||||||||||||||||||||||
908 | { | - | ||||||||||||||||||||||||
909 | if (matched_ent
| 19-59 | ||||||||||||||||||||||||
910 | * executed 59 times by 4 tests: matched_ent = data;*matched_ent = data; Executed by:
executed 59 times by 4 tests: *matched_ent = data; Executed by:
| 59 | ||||||||||||||||||||||||
911 | return executed 78 times by 4 tests: 0;return 0; Executed by:
executed 78 times by 4 tests: return 0; Executed by:
| 78 | ||||||||||||||||||||||||
912 | } | - | ||||||||||||||||||||||||
913 | - | |||||||||||||||||||||||||
914 | - | |||||||||||||||||||||||||
915 | - | |||||||||||||||||||||||||
916 | - | |||||||||||||||||||||||||
917 | - | |||||||||||||||||||||||||
918 | - | |||||||||||||||||||||||||
919 | if (table->n_buckets_used
| 26-20976 | ||||||||||||||||||||||||
920 | > table->tuning->growth_threshold * table->n_buckets
| 26-20976 | ||||||||||||||||||||||||
921 | { | - | ||||||||||||||||||||||||
922 | - | |||||||||||||||||||||||||
923 | - | |||||||||||||||||||||||||
924 | check_tuning (table); | - | ||||||||||||||||||||||||
925 | if (table->n_buckets_used
| 0-26 | ||||||||||||||||||||||||
926 | > table->tuning->growth_threshold * table->n_buckets
| 0-26 | ||||||||||||||||||||||||
927 | { | - | ||||||||||||||||||||||||
928 | const Hash_tuning *tuning = table->tuning; | - | ||||||||||||||||||||||||
929 | float candidate = | - | ||||||||||||||||||||||||
930 | (tuning->is_n_buckets
| 0-26 | ||||||||||||||||||||||||
931 | ? (table->n_buckets * tuning->growth_factor) | - | ||||||||||||||||||||||||
932 | : (table->n_buckets * tuning->growth_factor | - | ||||||||||||||||||||||||
933 | * tuning->growth_threshold)); | - | ||||||||||||||||||||||||
934 | - | |||||||||||||||||||||||||
935 | if ( | - | ||||||||||||||||||||||||
936 | (
| 0-26 | ||||||||||||||||||||||||
937 | <= candidate
| 0-26 | ||||||||||||||||||||||||
938 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||
939 | - | |||||||||||||||||||||||||
940 | - | |||||||||||||||||||||||||
941 | if (!hash_rehash (table, candidate)
| 0-26 | ||||||||||||||||||||||||
942 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||
943 | - | |||||||||||||||||||||||||
944 | - | |||||||||||||||||||||||||
945 | if (hash_find_entry (table, entry, &bucket,
| 0-26 | ||||||||||||||||||||||||
946 | 0
| 0-26 | ||||||||||||||||||||||||
947 | ) !=
| 0-26 | ||||||||||||||||||||||||
948 | ((void *)0)
| 0-26 | ||||||||||||||||||||||||
949 | ) | - | ||||||||||||||||||||||||
950 | abort (); never executed: abort (); | 0 | ||||||||||||||||||||||||
951 | } executed 26 times by 3 tests: end of block Executed by:
| 26 | ||||||||||||||||||||||||
952 | } executed 26 times by 3 tests: end of block Executed by:
| 26 | ||||||||||||||||||||||||
953 | - | |||||||||||||||||||||||||
954 | - | |||||||||||||||||||||||||
955 | - | |||||||||||||||||||||||||
956 | if (bucket->data
| 8205-12797 | ||||||||||||||||||||||||
957 | { | - | ||||||||||||||||||||||||
958 | struct hash_entry *new_entry = allocate_entry (table); | - | ||||||||||||||||||||||||
959 | - | |||||||||||||||||||||||||
960 | if (new_entry ==
| 0-8205 | ||||||||||||||||||||||||
961 | ((void *)0)
| 0-8205 | ||||||||||||||||||||||||
962 | ) | - | ||||||||||||||||||||||||
963 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||
964 | - | |||||||||||||||||||||||||
965 | - | |||||||||||||||||||||||||
966 | - | |||||||||||||||||||||||||
967 | new_entry->data = (void *) entry; | - | ||||||||||||||||||||||||
968 | new_entry->next = bucket->next; | - | ||||||||||||||||||||||||
969 | bucket->next = new_entry; | - | ||||||||||||||||||||||||
970 | table->n_entries++; | - | ||||||||||||||||||||||||
971 | return executed 8205 times by 7 tests: 1;return 1; Executed by:
executed 8205 times by 7 tests: return 1; Executed by:
| 8205 | ||||||||||||||||||||||||
972 | } | - | ||||||||||||||||||||||||
973 | - | |||||||||||||||||||||||||
974 | - | |||||||||||||||||||||||||
975 | - | |||||||||||||||||||||||||
976 | bucket->data = (void *) entry; | - | ||||||||||||||||||||||||
977 | table->n_entries++; | - | ||||||||||||||||||||||||
978 | table->n_buckets_used++; | - | ||||||||||||||||||||||||
979 | - | |||||||||||||||||||||||||
980 | return executed 12797 times by 16 tests: 1;return 1; Executed by:
executed 12797 times by 16 tests: return 1; Executed by:
| 12797 | ||||||||||||||||||||||||
981 | } | - | ||||||||||||||||||||||||
982 | - | |||||||||||||||||||||||||
983 | - | |||||||||||||||||||||||||
984 | - | |||||||||||||||||||||||||
985 | - | |||||||||||||||||||||||||
986 | - | |||||||||||||||||||||||||
987 | - | |||||||||||||||||||||||||
988 | - | |||||||||||||||||||||||||
989 | void * | - | ||||||||||||||||||||||||
990 | hash_insert (Hash_table *table, void const *entry) | - | ||||||||||||||||||||||||
991 | { | - | ||||||||||||||||||||||||
992 | void const *matched_ent; | - | ||||||||||||||||||||||||
993 | int err = hash_insert_if_absent (table, entry, &matched_ent); | - | ||||||||||||||||||||||||
994 | return executed 18473 times by 16 tests: (err == -1return (err == -1 ? ((void *)0) : (void *) (err == 0 ? matched_ent : entry)); Executed by:
executed 18473 times by 16 tests: return (err == -1 ? ((void *)0) : (void *) (err == 0 ? matched_ent : entry)); Executed by:
| 18473 | ||||||||||||||||||||||||
995 | ? executed 18473 times by 16 tests: return (err == -1 ? ((void *)0) : (void *) (err == 0 ? matched_ent : entry)); Executed by:
| 18473 | ||||||||||||||||||||||||
996 | ((void *)0) executed 18473 times by 16 tests: return (err == -1 ? ((void *)0) : (void *) (err == 0 ? matched_ent : entry)); Executed by:
| 18473 | ||||||||||||||||||||||||
997 | executed 18473 times by 16 tests: return (err == -1 ? ((void *)0) : (void *) (err == 0 ? matched_ent : entry)); Executed by:
| 18473 | ||||||||||||||||||||||||
998 | : (void *) (err == 0 ? matched_ent : entry)); executed 18473 times by 16 tests: return (err == -1 ? ((void *)0) : (void *) (err == 0 ? matched_ent : entry)); Executed by:
| 18473 | ||||||||||||||||||||||||
999 | } | - | ||||||||||||||||||||||||
1000 | - | |||||||||||||||||||||||||
1001 | - | |||||||||||||||||||||||||
1002 | - | |||||||||||||||||||||||||
1003 | - | |||||||||||||||||||||||||
1004 | - | |||||||||||||||||||||||||
1005 | void * | - | ||||||||||||||||||||||||
1006 | hash_delete (Hash_table *table, const void *entry) | - | ||||||||||||||||||||||||
1007 | { | - | ||||||||||||||||||||||||
1008 | void *data; | - | ||||||||||||||||||||||||
1009 | struct hash_entry *bucket; | - | ||||||||||||||||||||||||
1010 | - | |||||||||||||||||||||||||
1011 | data = hash_find_entry (table, entry, &bucket, | - | ||||||||||||||||||||||||
1012 | 1 | - | ||||||||||||||||||||||||
1013 | ); | - | ||||||||||||||||||||||||
1014 | if (!data
| 270-5376 | ||||||||||||||||||||||||
1015 | return executed 270 times by 5 tests: return ((void *)0) ; Executed by:
executed 270 times by 5 tests: return ((void *)0) ; Executed by:
| 270 | ||||||||||||||||||||||||
1016 | ((void *)0) executed 270 times by 5 tests: return ((void *)0) ; Executed by:
| 270 | ||||||||||||||||||||||||
1017 | ; executed 270 times by 5 tests: return ((void *)0) ; Executed by:
| 270 | ||||||||||||||||||||||||
1018 | - | |||||||||||||||||||||||||
1019 | table->n_entries--; | - | ||||||||||||||||||||||||
1020 | if (!bucket->data
| 212-5164 | ||||||||||||||||||||||||
1021 | { | - | ||||||||||||||||||||||||
1022 | table->n_buckets_used--; | - | ||||||||||||||||||||||||
1023 | - | |||||||||||||||||||||||||
1024 | - | |||||||||||||||||||||||||
1025 | - | |||||||||||||||||||||||||
1026 | - | |||||||||||||||||||||||||
1027 | if (table->n_buckets_used
| 0-5164 | ||||||||||||||||||||||||
1028 | < table->tuning->shrink_threshold * table->n_buckets
| 0-5164 | ||||||||||||||||||||||||
1029 | { | - | ||||||||||||||||||||||||
1030 | - | |||||||||||||||||||||||||
1031 | - | |||||||||||||||||||||||||
1032 | check_tuning (table); | - | ||||||||||||||||||||||||
1033 | if (table->n_buckets_used
| 0 | ||||||||||||||||||||||||
1034 | < table->tuning->shrink_threshold * table->n_buckets
| 0 | ||||||||||||||||||||||||
1035 | { | - | ||||||||||||||||||||||||
1036 | const Hash_tuning *tuning = table->tuning; | - | ||||||||||||||||||||||||
1037 | size_t candidate = | - | ||||||||||||||||||||||||
1038 | (tuning->is_n_buckets
| 0 | ||||||||||||||||||||||||
1039 | ? table->n_buckets * tuning->shrink_factor | - | ||||||||||||||||||||||||
1040 | : (table->n_buckets * tuning->shrink_factor | - | ||||||||||||||||||||||||
1041 | * tuning->growth_threshold)); | - | ||||||||||||||||||||||||
1042 | - | |||||||||||||||||||||||||
1043 | if (!hash_rehash (table, candidate)
| 0 | ||||||||||||||||||||||||
1044 | { | - | ||||||||||||||||||||||||
1045 | - | |||||||||||||||||||||||||
1046 | - | |||||||||||||||||||||||||
1047 | - | |||||||||||||||||||||||||
1048 | - | |||||||||||||||||||||||||
1049 | - | |||||||||||||||||||||||||
1050 | - | |||||||||||||||||||||||||
1051 | struct hash_entry *cursor = table->free_entry_list; | - | ||||||||||||||||||||||||
1052 | struct hash_entry *next; | - | ||||||||||||||||||||||||
1053 | while (cursor
| 0 | ||||||||||||||||||||||||
1054 | { | - | ||||||||||||||||||||||||
1055 | next = cursor->next; | - | ||||||||||||||||||||||||
1056 | free (cursor); | - | ||||||||||||||||||||||||
1057 | cursor = next; | - | ||||||||||||||||||||||||
1058 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1059 | table->free_entry_list = | - | ||||||||||||||||||||||||
1060 | ((void *)0) | - | ||||||||||||||||||||||||
1061 | ; | - | ||||||||||||||||||||||||
1062 | - | |||||||||||||||||||||||||
1063 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1064 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1065 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1066 | } executed 5164 times by 7 tests: end of block Executed by:
| 5164 | ||||||||||||||||||||||||
1067 | - | |||||||||||||||||||||||||
1068 | return executed 5376 times by 7 tests: data;return data; Executed by:
executed 5376 times by 7 tests: return data; Executed by:
| 5376 | ||||||||||||||||||||||||
1069 | } | - | ||||||||||||||||||||||||
Switch to Source code | Preprocessed file |