Debian Codegraph @

src/common/hashtable.cpp

raw symbols SCIP
1 /*
2 * Copyright (C) 2000,2001 Ross Combs ([email protected])
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18 #define HASHTABLE_INTERNAL_ACCESScxx . . $ `src/common/hashtable.cpp:18:9`!
19 #include "common/setup_before.h"cxx . . $ `<file>/src/common/setup_before.h`/
20 #include "common/hashtable.h"cxx . . $ `<file>/src/common/hashtable.h`/
21
22 #include "common/eventlog.h"cxx . . $ `<file>/src/common/eventlog.h`/
23 #include "common/xalloc.h"cxx . . $ `<file>/src/common/xalloc.h`/
24 #include "common/setup_after.h"cxx . . $ `<file>/src/common/setup_after.h`/
25
26
27 namespace pvpgncxx . . $ pvpgn/
28 {
29
30 static int nodatacxx . . $ pvpgn/nodata.; /* if data points to this, then the entry was actually deleted */
31
32
33 static t_entrycxx . . $ pvpgn/t_entry# * hashtable_entry_exportcxx . . $ pvpgn/hashtable_entry_export(c7760a94f4abe54e).(t_internentrycxx . . $ pvpgn/t_internentry# * entry, t_hashtablecxx . . $ pvpgn/t_hashtable# const * hashtable, unsigned int row);
34
35
36 static t_entrycxx . . $ pvpgn/t_entry# * hashtable_entry_exportcxx . . $ pvpgn/hashtable_entry_export(c7760a94f4abe54e).(t_internentrycxx . . $ pvpgn/t_internentry# * entry, t_hashtablecxx . . $ pvpgn/t_hashtable# const * hashtable, unsigned int row)
37 {
38 t_entrycxx . . $ pvpgn/t_entry# * temp;
39
40 if (!entry)
41 {
42 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL entry");
43 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
44 }
45 if (!hashtable)
46 {
47 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL hashtable");
48 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
49 }
50 if (row >= hashtable->num_rowscxx . . $ pvpgn/hashtable#num_rows.)
51 {
52 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got bad row {} (max {})", row, hashtable->num_rowscxx . . $ pvpgn/hashtable#num_rows. - 1);
53 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
54 }
55
56 temp = (t_entrycxx . . $ pvpgn/t_entry#*)xmalloccxx . . $ `src/common/xalloc.h:43:9`!(sizeof(t_entry));
57 temp->rowcxx . . $ pvpgn/entry#row. = row;
58 temp->realcxx . . $ pvpgn/entry#real. = entry;
59 temp->hashtablecxx . . $ pvpgn/entry#hashtable. = hashtable;
60
61 return temp;
62 }
63
64
65 extern t_hashtablecxx . . $ pvpgn/t_hashtable# * hashtable_createcxx . . $ pvpgn/hashtable_create(7bfadb07e2d0490a).(unsigned int num_rows)
66 {
67 t_hashtablecxx . . $ pvpgn/t_hashtable# * newh;
68 unsigned int i;
69
70 if (num_rows < 1)
71 {
72 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "num_rows must be at least 1");
73 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
74 }
75
76 newh = (t_hashtablecxx . . $ pvpgn/t_hashtable#*)xmalloccxx . . $ `src/common/xalloc.h:43:9`!(sizeof(t_hashtable));
77 newh->rowscxx . . $ pvpgn/hashtable#rows. = (t_internentrycxx . . $ pvpgn/t_internentry#**)xmalloccxx . . $ `src/common/xalloc.h:43:9`!(sizeof(t_internentry *)*num_rows);
78 newh->num_rowscxx . . $ pvpgn/hashtable#num_rows. = num_rows;
79 newh->lencxx . . $ pvpgn/hashtable#len. = 0;
80 for (i = 0; i < num_rows; i++)
81 newh->rowscxx . . $ pvpgn/hashtable#rows.[i] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
82
83 return newh;
84 }
85
86
87 extern int hashtable_destroycxx . . $ pvpgn/hashtable_destroy(8afcf31a4e16cf42).(t_hashtablecxx . . $ pvpgn/t_hashtable# * hashtable)
88 {
89 unsigned int i;
90
91 if (!hashtable)
92 {
93 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL hashtable");
94 return -1;
95 }
96
97 hashtable_purgecxx . . $ pvpgn/hashtable_purge(8afcf31a4e16cf42).(hashtable);
98 for (i = 0; i < hashtable->num_rowscxx . . $ pvpgn/hashtable#num_rows.; i++)
99 if (hashtable->rowscxx . . $ pvpgn/hashtable#rows.[i])
100 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got non-empty hashtable");
101
102 xfreecxx . . $ `src/common/xalloc.h:51:9`!(hashtable->rows);
103 xfreecxx . . $ `src/common/xalloc.h:51:9`!(hashtable);
104
105 return 0;
106 }
107
108
109 extern int hashtable_purgecxx . . $ pvpgn/hashtable_purge(8afcf31a4e16cf42).(t_hashtablecxx . . $ pvpgn/t_hashtable# * hashtable)
110 {
111 unsigned int row;
112 t_internentrycxx . . $ pvpgn/t_internentry# * curr;
113 t_internentrycxx . . $ pvpgn/t_internentry# * head;
114 t_internentrycxx . . $ pvpgn/t_internentry# * next;
115 t_internentrycxx . . $ pvpgn/t_internentry# * * change;
116
117 if (!hashtable)
118 {
119 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL hashtable");
120 return -1;
121 }
122
123 for (row = 0; row < hashtable->num_rowscxx . . $ pvpgn/hashtable#num_rows.; row++)
124 {
125 head = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
126 change = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
127 for (curr = hashtable->rowscxx . . $ pvpgn/hashtable#rows.[row]; curr; curr = next)
128 {
129 next = curr->nextcxx . . $ pvpgn/internentry#next.;
130 if (curr->datacxx . . $ pvpgn/internentry#data. == &nodatacxx . . $ pvpgn/nodata.)
131 {
132 if (change)
133 *change = next;
134 xfreecxx . . $ `src/common/xalloc.h:51:9`!(curr);
135 }
136 else
137 {
138 if (!head)
139 head = curr;
140 change = &curr->nextcxx . . $ pvpgn/internentry#next.;
141 }
142 }
143 hashtable->rowscxx . . $ pvpgn/hashtable#rows.[row] = head;
144 }
145
146 return 0;
147 }
148
149 extern unsigned int hashtable_get_lengthcxx . . $ pvpgn/hashtable_get_length(cf8ce18ab63d7d2c).(t_hashtablecxx . . $ pvpgn/t_hashtable# const * hashtable)
150 {
151 if (!hashtable)
152 {
153 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL hashtable");
154 return 0;
155 }
156
157 return hashtable->lencxx . . $ pvpgn/hashtable#len.;
158 }
159
160
161 extern int hashtable_insert_datacxx . . $ pvpgn/hashtable_insert_data(e38f1de6fd62ec3a).(t_hashtablecxx . . $ pvpgn/t_hashtable# * hashtable, void * data, unsigned int hash)
162 {
163 unsigned int row;
164 t_internentrycxx . . $ pvpgn/t_internentry# * entry;
165
166 if (!hashtable)
167 {
168 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL hashtable");
169 return -1;
170 }
171
172 entry = (t_internentrycxx . . $ pvpgn/t_internentry#*)xmalloccxx . . $ `src/common/xalloc.h:43:9`!(sizeof(t_internentry));
173 entry->datacxx . . $ pvpgn/internentry#data. = data;
174
175 row = hash%hashtable->num_rowscxx . . $ pvpgn/hashtable#num_rows.;
176 entry->nextcxx . . $ pvpgn/internentry#next. = hashtable->rowscxx . . $ pvpgn/hashtable#rows.[row];
177 hashtable->rowscxx . . $ pvpgn/hashtable#rows.[row] = entry;
178 hashtable->lencxx . . $ pvpgn/hashtable#len.++;
179
180 return 0;
181 }
182
183
184 extern t_entrycxx . . $ pvpgn/t_entry# * hashtable_get_entry_by_datacxx . . $ pvpgn/hashtable_get_entry_by_data(e55fbe464426d824).(t_hashtablecxx . . $ pvpgn/t_hashtable# const * hashtable, void const * data, unsigned int hash)
185 {
186 unsigned int row;
187 t_internentrycxx . . $ pvpgn/t_internentry# * curr;
188
189 if (!hashtable)
190 {
191 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL hashtable");
192 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
193 }
194
195 row = hash%hashtable->num_rowscxx . . $ pvpgn/hashtable#num_rows.;
196 for (curr = hashtable->rowscxx . . $ pvpgn/hashtable#rows.[row]; curr; curr = curr->nextcxx . . $ pvpgn/internentry#next.)
197 if (curr->datacxx . . $ pvpgn/internentry#data. == data)
198 return hashtable_entry_exportcxx . . $ pvpgn/hashtable_entry_export(c7760a94f4abe54e).(curr, hashtable, row);
199
200 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
201 }
202
203
204 extern t_entrycxx . . $ pvpgn/t_entry# const * hashtable_get_entry_by_data_constcxx . . $ pvpgn/hashtable_get_entry_by_data_const(534dc66aa9b8719c).(t_hashtablecxx . . $ pvpgn/t_hashtable# const * hashtable, void const * data, unsigned int hash)
205 {
206 unsigned int row;
207 t_internentrycxx . . $ pvpgn/t_internentry# * curr;
208
209 if (!hashtable)
210 {
211 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL hashtable");
212 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
213 }
214
215 row = hash%hashtable->num_rowscxx . . $ pvpgn/hashtable#num_rows.;
216 for (curr = hashtable->rowscxx . . $ pvpgn/hashtable#rows.[row]; curr; curr = curr->nextcxx . . $ pvpgn/internentry#next.)
217 if (curr->datacxx . . $ pvpgn/internentry#data. == data)
218 return hashtable_entry_exportcxx . . $ pvpgn/hashtable_entry_export(c7760a94f4abe54e).(curr, hashtable, row);
219
220 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
221 }
222
223
224 extern int hashtable_remove_entrycxx . . $ pvpgn/hashtable_remove_entry(1b043d8f0bcccff1).(t_hashtablecxx . . $ pvpgn/t_hashtable# * hashtable, t_entrycxx . . $ pvpgn/t_entry# * entry)
225 {
226 if (!hashtable)
227 {
228 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL hashtable");
229 return -1;
230 }
231 if (!entry)
232 {
233 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL entry");
234 return -1;
235 }
236 if (!entry->realcxx . . $ pvpgn/entry#real.)
237 {
238 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "entry has NULL real pointer");
239 return -1;
240 }
241 if (entry->realcxx . . $ pvpgn/entry#real.->datacxx . . $ pvpgn/internentry#data. == &nodatacxx . . $ pvpgn/nodata.)
242 {
243 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got deleted entry");
244 return -1;
245 }
246
247 entry->realcxx . . $ pvpgn/entry#real.->datacxx . . $ pvpgn/internentry#data. = &nodatacxx . . $ pvpgn/nodata.;
248 hashtable->lencxx . . $ pvpgn/hashtable#len.--;
249
250 return 0;
251 }
252
253
254 extern int hashtable_remove_datacxx . . $ pvpgn/hashtable_remove_data(c6644015312508b0).(t_hashtablecxx . . $ pvpgn/t_hashtable# * hashtable, void const * data, unsigned int hash)
255 {
256 t_entrycxx . . $ pvpgn/t_entry# * entry;
257 int retval;
258
259 if (!hashtable)
260 {
261 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL hashtable");
262 return -1;
263 }
264
265 if (!(entry = hashtable_get_entry_by_datacxx . . $ pvpgn/hashtable_get_entry_by_data(e55fbe464426d824).(hashtable, data, hash)))
266 return -1;
267
268 retval = hashtable_remove_entrycxx . . $ pvpgn/hashtable_remove_entry(1b043d8f0bcccff1).(hashtable, entry);
269
270 hashtable_entry_releasecxx . . $ pvpgn/hashtable_entry_release(ac222f288a486716).(entry);
271
272 return retval;
273 }
274
275
276 extern void * entry_get_datacxx . . $ pvpgn/entry_get_data(ad401fc46215ce52).(t_entrycxx . . $ pvpgn/t_entry# const * entry)
277 {
278 if (!entry)
279 {
280 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL entry");
281 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
282 }
283 if (!entry->realcxx . . $ pvpgn/entry#real.)
284 {
285 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "entry has NULL real pointer");
286 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
287 }
288 if (entry->realcxx . . $ pvpgn/entry#real.->datacxx . . $ pvpgn/internentry#data. == &nodatacxx . . $ pvpgn/nodata.)
289 {
290 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got deleted entry");
291 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
292 }
293
294 return entry->realcxx . . $ pvpgn/entry#real.->datacxx . . $ pvpgn/internentry#data.;
295 }
296
297
298 extern void * hashtable_get_data_by_poscxx . . $ pvpgn/hashtable_get_data_by_pos(10be6e303e675c1f).(t_hashtablecxx . . $ pvpgn/t_hashtable# const * hashtable, unsigned int pos)
299 {
300 t_internentrycxx . . $ pvpgn/t_internentry# const * curr;
301 unsigned int row;
302 unsigned int len;
303
304 if (!hashtable)
305 {
306 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL hashtable");
307 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
308 }
309
310 len = 0;
311 row = 0;
312 curr = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
313 for (;;)
314 {
315 if (!curr)
316 {
317 if (row >= hashtable->num_rowscxx . . $ pvpgn/hashtable#num_rows.)
318 break;
319 curr = hashtable->rowscxx . . $ pvpgn/hashtable#rows.[row++];
320 continue;
321 }
322 if (curr->datacxx . . $ pvpgn/internentry#data. != &nodatacxx . . $ pvpgn/nodata. && len++ == pos)
323 return curr->datacxx . . $ pvpgn/internentry#data.;
324 curr = curr->nextcxx . . $ pvpgn/internentry#next.;
325 }
326
327 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "requested position {} but len={}", pos, len);
328 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
329 }
330
331
332 #ifdef HASHTABLE_DEBUG
333 extern t_entry * hashtable_get_first_real(t_hashtable const * hashtable, char const * fn, unsigned int ln)
334 #else
335 extern t_entrycxx . . $ pvpgn/t_entry# * hashtable_get_firstcxx . . $ pvpgn/hashtable_get_first(b903d86a7b8543ff).(t_hashtablecxx . . $ pvpgn/t_hashtable# const * hashtable)
336 #endif
337 {
338 unsigned int row;
339 t_internentrycxx . . $ pvpgn/t_internentry# * curr;
340
341 if (!hashtable)
342 {
343 #ifdef HASHTABLE_DEBUG
344 eventlog(eventlog_level_error, __FUNCTION__, "got NULL hashtable from {}:{}", fn, ln);
345 #else
346 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL hashtable");
347 #endif
348 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
349 }
350
351 for (row = 0; row < hashtable->num_rowscxx . . $ pvpgn/hashtable#num_rows.; row++)
352 for (curr = hashtable->rowscxx . . $ pvpgn/hashtable#rows.[row]; curr; curr = curr->nextcxx . . $ pvpgn/internentry#next.)
353 if (curr->datacxx . . $ pvpgn/internentry#data. != &nodatacxx . . $ pvpgn/nodata.)
354 return hashtable_entry_exportcxx . . $ pvpgn/hashtable_entry_export(c7760a94f4abe54e).(curr, hashtable, row);
355
356 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
357 }
358
359
360 extern t_entrycxx . . $ pvpgn/t_entry# * entry_get_nextcxx . . $ pvpgn/entry_get_next(e7e16cf9303dbb2b).(t_entrycxx . . $ pvpgn/t_entry# * entry)
361 {
362 t_hashtablecxx . . $ pvpgn/t_hashtable# const * hashtable;
363 unsigned int row;
364 t_internentrycxx . . $ pvpgn/t_internentry# * curr;
365
366 if (!entry)
367 {
368 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL entry");
369 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
370 }
371
372 hashtable = entry->hashtablecxx . . $ pvpgn/entry#hashtable.;
373
374 for (curr = entry->realcxx . . $ pvpgn/entry#real.->nextcxx . . $ pvpgn/internentry#next.; curr; curr = curr->nextcxx . . $ pvpgn/internentry#next.)
375 if (curr->datacxx . . $ pvpgn/internentry#data. != &nodatacxx . . $ pvpgn/nodata.)
376 {
377 entry->realcxx . . $ pvpgn/entry#real. = curr;
378 return entry;
379 }
380
381 for (row = entry->rowcxx . . $ pvpgn/entry#row. + 1; row < hashtable->num_rowscxx . . $ pvpgn/hashtable#num_rows.; row++)
382 for (curr = hashtable->rowscxx . . $ pvpgn/hashtable#rows.[row]; curr; curr = curr->nextcxx . . $ pvpgn/internentry#next.)
383 if (curr->datacxx . . $ pvpgn/internentry#data. != &nodatacxx . . $ pvpgn/nodata.)
384 {
385 entry->realcxx . . $ pvpgn/entry#real. = curr;
386 entry->rowcxx . . $ pvpgn/entry#row. = row;
387 return entry;
388 }
389
390 hashtable_entry_releasecxx . . $ pvpgn/hashtable_entry_release(ac222f288a486716).(entry);
391 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
392 }
393
394
395 #ifdef HASHTABLE_DEBUG
396 extern t_entry * hashtable_get_first_matching_real(t_hashtable const * hashtable, unsigned int hash, char const * fn, unsigned int ln)
397 #else
398 extern t_entrycxx . . $ pvpgn/t_entry# * hashtable_get_first_matchingcxx . . $ pvpgn/hashtable_get_first_matching(fdba7c131b4d72f1).(t_hashtablecxx . . $ pvpgn/t_hashtable# const * hashtable, unsigned int hash)
399 #endif
400 {
401 unsigned int row;
402 t_internentrycxx . . $ pvpgn/t_internentry# * curr;
403
404 if (!hashtable)
405 {
406 #ifdef HASHTABLE_DEBUG
407 eventlog(eventlog_level_error, __FUNCTION__, "got NULL hashtable from {}:{}", fn, ln);
408 #else
409 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL hashtable");
410 #endif
411 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
412 }
413
414 row = hash%hashtable->num_rowscxx . . $ pvpgn/hashtable#num_rows.;
415 for (curr = hashtable->rowscxx . . $ pvpgn/hashtable#rows.[row]; curr; curr = curr->nextcxx . . $ pvpgn/internentry#next.)
416 if (curr->datacxx . . $ pvpgn/internentry#data. != &nodatacxx . . $ pvpgn/nodata.)
417 return hashtable_entry_exportcxx . . $ pvpgn/hashtable_entry_export(c7760a94f4abe54e).(curr, hashtable, row);
418
419 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
420 }
421
422
423 extern t_entrycxx . . $ pvpgn/t_entry# * entry_get_next_matchingcxx . . $ pvpgn/entry_get_next_matching(e7e16cf9303dbb2b).(t_entrycxx . . $ pvpgn/t_entry# * entry)
424 {
425 t_internentrycxx . . $ pvpgn/t_internentry# * curr;
426
427 if (!entry)
428 {
429 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL entry");
430 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
431 }
432
433 for (curr = entry->realcxx . . $ pvpgn/entry#real.->nextcxx . . $ pvpgn/internentry#next.; curr; curr = curr->nextcxx . . $ pvpgn/internentry#next.)
434 if (curr->datacxx . . $ pvpgn/internentry#data. != &nodatacxx . . $ pvpgn/nodata.)
435 {
436 entry->realcxx . . $ pvpgn/entry#real. = curr;
437 return entry;
438 }
439
440 hashtable_entry_releasecxx . . $ pvpgn/hashtable_entry_release(ac222f288a486716).(entry);
441 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
442 }
443
444
445 extern int hashtable_entry_releasecxx . . $ pvpgn/hashtable_entry_release(ac222f288a486716).(t_entrycxx . . $ pvpgn/t_entry# * entry)
446 {
447 if (!entry)
448 {
449 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL entry");
450 return -1;
451 }
452 if (!entry->hashtablecxx . . $ pvpgn/entry#hashtable.)
453 {
454 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got entry with NULL hashtable");
455 return -1;
456 }
457 if (!entry->realcxx . . $ pvpgn/entry#real.)
458 {
459 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got entry with NULL real pointer");
460 return -1;
461 }
462 if (entry->rowcxx . . $ pvpgn/entry#row. >= entry->hashtablecxx . . $ pvpgn/entry#hashtable.->num_rowscxx . . $ pvpgn/hashtable#num_rows.)
463 {
464 eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "entry has bad row {} (max {})", entry->rowcxx . . $ pvpgn/entry#row., entry->hashtablecxx . . $ pvpgn/entry#hashtable.->num_rowscxx . . $ pvpgn/hashtable#num_rows. - 1);
465 return -1;
466 }
467
468 xfreecxx . . $ `src/common/xalloc.h:51:9`!(entry);
469 return 0;
470 }
471
472 }