• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

systemd / systemd / 14526975710

17 Apr 2025 09:06PM UTC coverage: 72.13% (+0.01%) from 72.117%
14526975710

push

github

yuwata
rules: Make ADB and fastboot work out-of-the-box

https://android.googlesource.com/platform/packages/modules/adb/+/d0db47dcd/adb.h#199
https://android.googlesource.com/platform/system/core/+/7199051aa/fastboot/fastboot.cpp#244

297093 of 411885 relevant lines covered (72.13%)

687643.53 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

98.21
/src/basic/hashmap.h
1
/* SPDX-License-Identifier: LGPL-2.1-or-later */
2
#pragma once
3

4
#include <limits.h>
5
#include <stdbool.h>
6
#include <stddef.h>
7

8
#include "hash-funcs.h"
9
#include "macro.h"
10

11
/*
12
 * A hash table implementation. As a minor optimization a NULL hashmap object
13
 * will be treated as empty hashmap for all read operations. That way it is not
14
 * necessary to instantiate an object for each Hashmap use.
15
 *
16
 * If ENABLE_DEBUG_HASHMAP is defined (by configuring with -Ddebug-extra=hashmap),
17
 * the implementation will:
18
 * - store extra data for debugging and statistics (see tools/gdb-sd_dump_hashmaps.py)
19
 * - perform extra checks for invalid use of iterators
20
 */
21

22
#define HASH_KEY_SIZE 16
23

24
typedef void* (*hashmap_destroy_t)(void *p);
25

26
/* The base type for all hashmap and set types. Many functions in the implementation take (HashmapBase*)
27
 * parameters and are run-time polymorphic, though the API is not meant to be polymorphic (do not call
28
 * underscore-prefixed functions directly). */
29
typedef struct HashmapBase HashmapBase;
30

31
/* Specific hashmap/set types */
32
typedef struct Hashmap Hashmap;               /* Maps keys to values */
33
typedef struct OrderedHashmap OrderedHashmap; /* Like Hashmap, but also remembers entry insertion order */
34
typedef struct Set Set;                       /* Stores just keys */
35

36
typedef struct IteratedCache IteratedCache;   /* Caches the iterated order of one of the above */
37

38
/* Ideally the Iterator would be an opaque struct, but it is instantiated
39
 * by hashmap users, so the definition has to be here. Do not use its fields
40
 * directly. */
41
typedef struct {
42
        const void *next_key; /* expected value of that entry's key pointer */
43
        unsigned idx;         /* index of an entry to be iterated next */
44
#if ENABLE_DEBUG_HASHMAP
45
        unsigned put_count;   /* hashmap's put_count recorded at start of iteration */
46
        unsigned rem_count;   /* hashmap's rem_count in previous iteration */
47
        unsigned prev_idx;    /* idx in previous iteration */
48
#endif
49
} Iterator;
50

51
#define _IDX_ITERATOR_FIRST (UINT_MAX - 1)
52
#define ITERATOR_FIRST ((Iterator) { .idx = _IDX_ITERATOR_FIRST, .next_key = NULL })
53
#define ITERATOR_IS_FIRST(i) ((i).idx == _IDX_ITERATOR_FIRST)
54

55
/* Macros for type checking */
56
#define PTR_COMPATIBLE_WITH_HASHMAP_BASE(h) \
57
        (__builtin_types_compatible_p(typeof(h), HashmapBase*) || \
58
         __builtin_types_compatible_p(typeof(h), Hashmap*) || \
59
         __builtin_types_compatible_p(typeof(h), OrderedHashmap*) || \
60
         __builtin_types_compatible_p(typeof(h), Set*))
61

62
#define PTR_COMPATIBLE_WITH_PLAIN_HASHMAP(h) \
63
        (__builtin_types_compatible_p(typeof(h), Hashmap*) || \
64
         __builtin_types_compatible_p(typeof(h), OrderedHashmap*)) \
65

66
#define HASHMAP_BASE(h) \
67
        __builtin_choose_expr(PTR_COMPATIBLE_WITH_HASHMAP_BASE(h), \
68
                (HashmapBase*)(h), \
69
                (void)0)
70

71
#define PLAIN_HASHMAP(h) \
72
        __builtin_choose_expr(PTR_COMPATIBLE_WITH_PLAIN_HASHMAP(h), \
73
                (Hashmap*)(h), \
74
                (void)0)
75

76
#if ENABLE_DEBUG_HASHMAP
77
# define HASHMAP_DEBUG_PARAMS , const char *func, const char *file, int line
78
# define HASHMAP_DEBUG_SRC_ARGS   , __func__, PROJECT_FILE, __LINE__
79
# define HASHMAP_DEBUG_PASS_ARGS   , func, file, line
80
#else
81
# define HASHMAP_DEBUG_PARAMS
82
# define HASHMAP_DEBUG_SRC_ARGS
83
# define HASHMAP_DEBUG_PASS_ARGS
84
#endif
85

86
Hashmap* _hashmap_new(const struct hash_ops *hash_ops  HASHMAP_DEBUG_PARAMS);
87
OrderedHashmap* _ordered_hashmap_new(const struct hash_ops *hash_ops  HASHMAP_DEBUG_PARAMS);
88
#define hashmap_new(ops) _hashmap_new(ops  HASHMAP_DEBUG_SRC_ARGS)
89
#define ordered_hashmap_new(ops) _ordered_hashmap_new(ops  HASHMAP_DEBUG_SRC_ARGS)
90

91
#define hashmap_free_and_replace(a, b)                          \
92
        free_and_replace_full(a, b, hashmap_free)
93
#define ordered_hashmap_free_and_replace(a, b)                  \
94
        free_and_replace_full(a, b, ordered_hashmap_free)
95

96
HashmapBase* _hashmap_free(HashmapBase *h, free_func_t default_free_key, free_func_t default_free_value);
97
static inline Hashmap* hashmap_free(Hashmap *h) {
3,997,833✔
98
        return (void*) _hashmap_free(HASHMAP_BASE(h), NULL, NULL);
3,473,821✔
99
}
100
static inline OrderedHashmap* ordered_hashmap_free(OrderedHashmap *h) {
4,381,285✔
101
        return (void*) _hashmap_free(HASHMAP_BASE(h), NULL, NULL);
3,191,245✔
102
}
103

104
IteratedCache* iterated_cache_free(IteratedCache *cache);
105
int iterated_cache_get(IteratedCache *cache, const void ***res_keys, const void ***res_values, unsigned *res_n_entries);
106

107
HashmapBase* _hashmap_copy(HashmapBase *h  HASHMAP_DEBUG_PARAMS);
108
#define hashmap_copy(h) ((Hashmap*) _hashmap_copy(HASHMAP_BASE(h)  HASHMAP_DEBUG_SRC_ARGS))
109
#define ordered_hashmap_copy(h) ((OrderedHashmap*) _hashmap_copy(HASHMAP_BASE(h)  HASHMAP_DEBUG_SRC_ARGS))
110

111
int _hashmap_ensure_allocated(Hashmap **h, const struct hash_ops *hash_ops  HASHMAP_DEBUG_PARAMS);
112
int _hashmap_ensure_put(Hashmap **h, const struct hash_ops *hash_ops, const void *key, void *value  HASHMAP_DEBUG_PARAMS);
113
int _ordered_hashmap_ensure_allocated(OrderedHashmap **h, const struct hash_ops *hash_ops  HASHMAP_DEBUG_PARAMS);
114
int _hashmap_ensure_replace(Hashmap **h, const struct hash_ops *hash_ops, const void *key, void *value  HASHMAP_DEBUG_PARAMS);
115

116
#define hashmap_ensure_allocated(h, ops) _hashmap_ensure_allocated(h, ops  HASHMAP_DEBUG_SRC_ARGS)
117
#define hashmap_ensure_put(s, ops, key, value) _hashmap_ensure_put(s, ops, key, value  HASHMAP_DEBUG_SRC_ARGS)
118
#define ordered_hashmap_ensure_allocated(h, ops) _ordered_hashmap_ensure_allocated(h, ops  HASHMAP_DEBUG_SRC_ARGS)
119
#define hashmap_ensure_replace(s, ops, key, value) _hashmap_ensure_replace(s, ops, key, value  HASHMAP_DEBUG_SRC_ARGS)
120

121
int _ordered_hashmap_ensure_put(OrderedHashmap **h, const struct hash_ops *hash_ops, const void *key, void *value  HASHMAP_DEBUG_PARAMS);
122
#define ordered_hashmap_ensure_put(s, ops, key, value) _ordered_hashmap_ensure_put(s, ops, key, value  HASHMAP_DEBUG_SRC_ARGS)
123

124
int _ordered_hashmap_ensure_replace(OrderedHashmap **h, const struct hash_ops *hash_ops, const void *key, void *value  HASHMAP_DEBUG_PARAMS);
125
#define ordered_hashmap_ensure_replace(s, ops, key, value) _ordered_hashmap_ensure_replace(s, ops, key, value  HASHMAP_DEBUG_SRC_ARGS)
126

127
IteratedCache* _hashmap_iterated_cache_new(HashmapBase *h);
128
static inline IteratedCache* hashmap_iterated_cache_new(Hashmap *h) {
1✔
129
        return (IteratedCache*) _hashmap_iterated_cache_new(HASHMAP_BASE(h));
1✔
130
}
131
static inline IteratedCache* ordered_hashmap_iterated_cache_new(OrderedHashmap *h) {
6,276✔
132
        return (IteratedCache*) _hashmap_iterated_cache_new(HASHMAP_BASE(h));
6,276✔
133
}
134

135
int hashmap_put(Hashmap *h, const void *key, void *value);
136
static inline int ordered_hashmap_put(OrderedHashmap *h, const void *key, void *value) {
7,957,898✔
137
        return hashmap_put(PLAIN_HASHMAP(h), key, value);
7,957,873✔
138
}
139

140
int _hashmap_put_strdup_full(Hashmap **h, const struct hash_ops *hash_ops, const char *k, const char *v  HASHMAP_DEBUG_PARAMS);
141
#define hashmap_put_strdup_full(h, hash_ops, k, v) _hashmap_put_strdup_full(h, hash_ops, k, v  HASHMAP_DEBUG_SRC_ARGS)
142
#define hashmap_put_strdup(h, k, v) hashmap_put_strdup_full(h, &string_hash_ops_free_free, k, v)
143

144
int hashmap_update(Hashmap *h, const void *key, void *value);
145
static inline int ordered_hashmap_update(OrderedHashmap *h, const void *key, void *value) {
4✔
146
        return hashmap_update(PLAIN_HASHMAP(h), key, value);
4✔
147
}
148

149
int hashmap_replace(Hashmap *h, const void *key, void *value);
150
static inline int ordered_hashmap_replace(OrderedHashmap *h, const void *key, void *value) {
12,007,306✔
151
        return hashmap_replace(PLAIN_HASHMAP(h), key, value);
12,007,306✔
152
}
153

154
void* _hashmap_get(HashmapBase *h, const void *key);
155
static inline void *hashmap_get(Hashmap *h, const void *key) {
27,461,425✔
156
        return _hashmap_get(HASHMAP_BASE(h), key);
26,895,304✔
157
}
158
static inline void *ordered_hashmap_get(OrderedHashmap *h, const void *key) {
29,321,170✔
159
        return _hashmap_get(HASHMAP_BASE(h), key);
29,321,170✔
160
}
161

162
void* hashmap_get2(Hashmap *h, const void *key, void **rkey);
163
static inline void *ordered_hashmap_get2(OrderedHashmap *h, const void *key, void **rkey) {
11,999,527✔
164
        return hashmap_get2(PLAIN_HASHMAP(h), key, rkey);
11,999,527✔
165
}
166

167
bool _hashmap_contains(HashmapBase *h, const void *key);
168
static inline bool hashmap_contains(Hashmap *h, const void *key) {
1,236,273✔
169
        return _hashmap_contains(HASHMAP_BASE(h), key);
1,236,273✔
170
}
171
static inline bool ordered_hashmap_contains(OrderedHashmap *h, const void *key) {
17,479✔
172
        return _hashmap_contains(HASHMAP_BASE(h), key);
18,559✔
173
}
174

175
void* _hashmap_remove(HashmapBase *h, const void *key);
176
static inline void *hashmap_remove(Hashmap *h, const void *key) {
6,861,963✔
177
        return _hashmap_remove(HASHMAP_BASE(h), key);
6,858,222✔
178
}
179
static inline void *ordered_hashmap_remove(OrderedHashmap *h, const void *key) {
64,096✔
180
        return _hashmap_remove(HASHMAP_BASE(h), key);
64,096✔
181
}
182

183
void* hashmap_remove2(Hashmap *h, const void *key, void **rkey);
184
static inline void *ordered_hashmap_remove2(OrderedHashmap *h, const void *key, void **rkey) {
558,079✔
185
        return hashmap_remove2(PLAIN_HASHMAP(h), key, rkey);
558,079✔
186
}
187

188
void* _hashmap_remove_value(HashmapBase *h, const void *key, void *value);
189
static inline void *hashmap_remove_value(Hashmap *h, const void *key, void *value) {
348,932✔
190
        return _hashmap_remove_value(HASHMAP_BASE(h), key, value);
348,842✔
191
}
192

193
static inline void* ordered_hashmap_remove_value(OrderedHashmap *h, const void *key, void *value) {
91,714✔
194
        return hashmap_remove_value(PLAIN_HASHMAP(h), key, value);
91,714✔
195
}
196

197
int hashmap_remove_and_put(Hashmap *h, const void *old_key, const void *new_key, void *value);
198
static inline int ordered_hashmap_remove_and_put(OrderedHashmap *h, const void *old_key, const void *new_key, void *value) {
4✔
199
        return hashmap_remove_and_put(PLAIN_HASHMAP(h), old_key, new_key, value);
4✔
200
}
201

202
int hashmap_remove_and_replace(Hashmap *h, const void *old_key, const void *new_key, void *value);
203
static inline int ordered_hashmap_remove_and_replace(OrderedHashmap *h, const void *old_key, const void *new_key, void *value) {
24✔
204
        return hashmap_remove_and_replace(PLAIN_HASHMAP(h), old_key, new_key, value);
24✔
205
}
206

207
/* Since merging data from an OrderedHashmap into a Hashmap or vice-versa
208
 * should just work, allow this by having looser type-checking here. */
209
int _hashmap_merge(Hashmap *h, Hashmap *other);
210
#define hashmap_merge(h, other) _hashmap_merge(PLAIN_HASHMAP(h), PLAIN_HASHMAP(other))
211
#define ordered_hashmap_merge(h, other) hashmap_merge(h, other)
212

213
int _hashmap_reserve(HashmapBase *h, unsigned entries_add);
214
static inline int hashmap_reserve(Hashmap *h, unsigned entries_add) {
16✔
215
        return _hashmap_reserve(HASHMAP_BASE(h), entries_add);
16✔
216
}
217
static inline int ordered_hashmap_reserve(OrderedHashmap *h, unsigned entries_add) {
1,484✔
218
        return _hashmap_reserve(HASHMAP_BASE(h), entries_add);
1,484✔
219
}
220

221
int _hashmap_move(HashmapBase *h, HashmapBase *other);
222
/* Unlike hashmap_merge, hashmap_move does not allow mixing the types. */
223
static inline int hashmap_move(Hashmap *h, Hashmap *other) {
2,479✔
224
        return _hashmap_move(HASHMAP_BASE(h), HASHMAP_BASE(other));
2,479✔
225
}
226
static inline int ordered_hashmap_move(OrderedHashmap *h, OrderedHashmap *other) {
2✔
227
        return _hashmap_move(HASHMAP_BASE(h), HASHMAP_BASE(other));
2✔
228
}
229

230
int _hashmap_move_one(HashmapBase *h, HashmapBase *other, const void *key);
231
static inline int hashmap_move_one(Hashmap *h, Hashmap *other, const void *key) {
5✔
232
        return _hashmap_move_one(HASHMAP_BASE(h), HASHMAP_BASE(other), key);
5✔
233
}
234
static inline int ordered_hashmap_move_one(OrderedHashmap *h, OrderedHashmap *other, const void *key) {
530✔
235
        return _hashmap_move_one(HASHMAP_BASE(h), HASHMAP_BASE(other), key);
530✔
236
}
237

238
unsigned _hashmap_size(HashmapBase *h) _pure_;
239
static inline unsigned hashmap_size(Hashmap *h) {
1,384,669✔
240
        return _hashmap_size(HASHMAP_BASE(h));
1,089,294✔
241
}
242
static inline unsigned ordered_hashmap_size(OrderedHashmap *h) {
9,100,956✔
243
        return _hashmap_size(HASHMAP_BASE(h));
9,006,497✔
244
}
245

246
static inline bool hashmap_isempty(Hashmap *h) {
912,773✔
247
        return hashmap_size(h) == 0;
850,131✔
248
}
249
static inline bool ordered_hashmap_isempty(OrderedHashmap *h) {
1,277,459✔
250
        return ordered_hashmap_size(h) == 0;
1,277,407✔
251
}
252

253
unsigned _hashmap_buckets(HashmapBase *h) _pure_;
254
static inline unsigned hashmap_buckets(Hashmap *h) {
2,054✔
255
        return _hashmap_buckets(HASHMAP_BASE(h));
2,054✔
256
}
257
static inline unsigned ordered_hashmap_buckets(OrderedHashmap *h) {
8✔
258
        return _hashmap_buckets(HASHMAP_BASE(h));
8✔
259
}
260

261
bool _hashmap_iterate(HashmapBase *h, Iterator *i, void **value, const void **key);
262
static inline bool hashmap_iterate(Hashmap *h, Iterator *i, void **value, const void **key) {
22,586,790✔
263
        return _hashmap_iterate(HASHMAP_BASE(h), i, value, key);
22,586,793✔
264
}
265
static inline bool ordered_hashmap_iterate(OrderedHashmap *h, Iterator *i, void **value, const void **key) {
8,784,503✔
266
        return _hashmap_iterate(HASHMAP_BASE(h), i, value, key);
8,784,503✔
267
}
268

269
void _hashmap_clear(HashmapBase *h, free_func_t default_free_key, free_func_t default_free_value);
270
static inline void hashmap_clear(Hashmap *h) {
111,849✔
271
        _hashmap_clear(HASHMAP_BASE(h), NULL, NULL);
111,849✔
272
}
92,496✔
273
static inline void ordered_hashmap_clear(OrderedHashmap *h) {
17,194✔
274
        _hashmap_clear(HASHMAP_BASE(h), NULL, NULL);
17,194✔
275
}
24✔
276

277
/*
278
 * Note about all *_first*() functions
279
 *
280
 * For plain Hashmaps and Sets the order of entries is undefined.
281
 * The functions find whatever entry is first in the implementation
282
 * internal order.
283
 *
284
 * Only for OrderedHashmaps the order is well defined and finding
285
 * the first entry is O(1).
286
 */
287

288
void *_hashmap_first_key_and_value(HashmapBase *h, bool remove, void **ret_key);
289
static inline void *hashmap_steal_first_key_and_value(Hashmap *h, void **ret) {
43,406✔
290
        return _hashmap_first_key_and_value(HASHMAP_BASE(h), true, ret);
43,406✔
291
}
292
static inline void *ordered_hashmap_steal_first_key_and_value(OrderedHashmap *h, void **ret) {
×
293
        return _hashmap_first_key_and_value(HASHMAP_BASE(h), true, ret);
×
294
}
295
static inline void *hashmap_first_key_and_value(Hashmap *h, void **ret) {
296
        return _hashmap_first_key_and_value(HASHMAP_BASE(h), false, ret);
297
}
298
static inline void *ordered_hashmap_first_key_and_value(OrderedHashmap *h, void **ret) {
299
        return _hashmap_first_key_and_value(HASHMAP_BASE(h), false, ret);
300
}
301

302
static inline void *hashmap_steal_first(Hashmap *h) {
377,983✔
303
        return _hashmap_first_key_and_value(HASHMAP_BASE(h), true, NULL);
377,983✔
304
}
305
static inline void *ordered_hashmap_steal_first(OrderedHashmap *h) {
7,604,167✔
306
        return _hashmap_first_key_and_value(HASHMAP_BASE(h), true, NULL);
7,604,167✔
307
}
308
static inline void *hashmap_first(Hashmap *h) {
50,823✔
309
        return _hashmap_first_key_and_value(HASHMAP_BASE(h), false, NULL);
50,823✔
310
}
311
static inline void *ordered_hashmap_first(OrderedHashmap *h) {
243,571✔
312
        return _hashmap_first_key_and_value(HASHMAP_BASE(h), false, NULL);
243,571✔
313
}
314

315
static inline void *_hashmap_first_key(HashmapBase *h, bool remove) {
893,965✔
316
        void *key = NULL;
893,965✔
317

318
        (void) _hashmap_first_key_and_value(HASHMAP_BASE(h), remove, &key);
893,965✔
319
        return key;
893,965✔
320
}
321
static inline void *hashmap_steal_first_key(Hashmap *h) {
877,313✔
322
        return _hashmap_first_key(HASHMAP_BASE(h), true);
877,313✔
323
}
324
static inline void *ordered_hashmap_steal_first_key(OrderedHashmap *h) {
2✔
325
        return _hashmap_first_key(HASHMAP_BASE(h), true);
2✔
326
}
327
static inline void *hashmap_first_key(Hashmap *h) {
16,266✔
328
        return _hashmap_first_key(HASHMAP_BASE(h), false);
16,266✔
329
}
330
static inline void *ordered_hashmap_first_key(OrderedHashmap *h) {
384✔
331
        return _hashmap_first_key(HASHMAP_BASE(h), false);
384✔
332
}
333

334
#define hashmap_clear_with_destructor(h, f)                     \
335
        ({                                                      \
336
                Hashmap *_h = (h);                              \
337
                void *_item;                                    \
338
                while ((_item = hashmap_steal_first(_h)))       \
339
                        f(_item);                               \
340
                _h;                                             \
341
        })
342
#define hashmap_free_with_destructor(h, f)                      \
343
        hashmap_free(hashmap_clear_with_destructor(h, f))
344
#define ordered_hashmap_clear_with_destructor(h, f)                     \
345
        ({                                                              \
346
                OrderedHashmap *_h = (h);                               \
347
                void *_item;                                            \
348
                while ((_item = ordered_hashmap_steal_first(_h)))       \
349
                        f(_item);                                       \
350
                _h;                                                     \
351
        })
352
#define ordered_hashmap_free_with_destructor(h, f)                      \
353
        ordered_hashmap_free(ordered_hashmap_clear_with_destructor(h, f))
354

355
/* no hashmap_next */
356
void* ordered_hashmap_next(OrderedHashmap *h, const void *key);
357

358
char** _hashmap_get_strv(HashmapBase *h);
359
static inline char** hashmap_get_strv(Hashmap *h) {
1✔
360
        return _hashmap_get_strv(HASHMAP_BASE(h));
1✔
361
}
362
static inline char** ordered_hashmap_get_strv(OrderedHashmap *h) {
1✔
363
        return _hashmap_get_strv(HASHMAP_BASE(h));
1✔
364
}
365

366
int _hashmap_dump_sorted(HashmapBase *h, void ***ret, size_t *ret_n);
367
static inline int hashmap_dump_sorted(Hashmap *h, void ***ret, size_t *ret_n) {
106,471✔
368
        return _hashmap_dump_sorted(HASHMAP_BASE(h), ret, ret_n);
106,471✔
369
}
370
static inline int ordered_hashmap_dump_sorted(OrderedHashmap *h, void ***ret, size_t *ret_n) {
4✔
371
        return _hashmap_dump_sorted(HASHMAP_BASE(h), ret, ret_n);
4✔
372
}
373
static inline int set_dump_sorted(Set *h, void ***ret, size_t *ret_n) {
435✔
374
        return _hashmap_dump_sorted(HASHMAP_BASE(h), ret, ret_n);
435✔
375
}
376

377
int _hashmap_dump_keys_sorted(HashmapBase *h, void ***ret, size_t *ret_n);
378
static inline int hashmap_dump_keys_sorted(Hashmap *h, void ***ret, size_t *ret_n) {
86✔
379
        return _hashmap_dump_keys_sorted(HASHMAP_BASE(h), ret, ret_n);
86✔
380
}
381
static inline int ordered_hashmap_dump_keys_sorted(OrderedHashmap *h, void ***ret, size_t *ret_n) {
2✔
382
        return _hashmap_dump_keys_sorted(HASHMAP_BASE(h), ret, ret_n);
2✔
383
}
384

385
/*
386
 * Hashmaps are iterated in unpredictable order.
387
 * OrderedHashmaps are an exception to this. They are iterated in the order
388
 * the entries were inserted.
389
 * It is safe to remove the current entry.
390
 */
391
#define _HASHMAP_BASE_FOREACH(e, h, i) \
392
        for (Iterator i = ITERATOR_FIRST; _hashmap_iterate((h), &i, (void**)&(e), NULL); )
393
#define HASHMAP_BASE_FOREACH(e, h) \
394
        _HASHMAP_BASE_FOREACH(e, h, UNIQ_T(i, UNIQ))
395

396
#define _HASHMAP_FOREACH(e, h, i) \
397
        for (Iterator i = ITERATOR_FIRST; hashmap_iterate((h), &i, (void**)&(e), NULL); )
398
#define HASHMAP_FOREACH(e, h) \
399
        _HASHMAP_FOREACH(e, h, UNIQ_T(i, UNIQ))
400

401
#define _ORDERED_HASHMAP_FOREACH(e, h, i) \
402
        for (Iterator i = ITERATOR_FIRST; ordered_hashmap_iterate((h), &i, (void**)&(e), NULL); )
403
#define ORDERED_HASHMAP_FOREACH(e, h) \
404
        _ORDERED_HASHMAP_FOREACH(e, h, UNIQ_T(i, UNIQ))
405

406
#define _HASHMAP_BASE_FOREACH_KEY(e, k, h, i) \
407
        for (Iterator i = ITERATOR_FIRST; _hashmap_iterate((h), &i, (void**)&(e), (const void**) &(k)); )
408
#define HASHMAP_BASE_FOREACH_KEY(e, k, h) \
409
        _HASHMAP_BASE_FOREACH_KEY(e, k, h, UNIQ_T(i, UNIQ))
410

411
#define _HASHMAP_FOREACH_KEY(e, k, h, i) \
412
        for (Iterator i = ITERATOR_FIRST; hashmap_iterate((h), &i, (void**)&(e), (const void**) &(k)); )
413
#define HASHMAP_FOREACH_KEY(e, k, h) \
414
        _HASHMAP_FOREACH_KEY(e, k, h, UNIQ_T(i, UNIQ))
415

416
#define _ORDERED_HASHMAP_FOREACH_KEY(e, k, h, i) \
417
        for (Iterator i = ITERATOR_FIRST; ordered_hashmap_iterate((h), &i, (void**)&(e), (const void**) &(k)); )
418
#define ORDERED_HASHMAP_FOREACH_KEY(e, k, h) \
419
        _ORDERED_HASHMAP_FOREACH_KEY(e, k, h, UNIQ_T(i, UNIQ))
420

421
DEFINE_TRIVIAL_CLEANUP_FUNC(Hashmap*, hashmap_free);
732,141✔
422
DEFINE_TRIVIAL_CLEANUP_FUNC(OrderedHashmap*, ordered_hashmap_free);
57,136✔
423

424
#define _cleanup_hashmap_free_ _cleanup_(hashmap_freep)
425
#define _cleanup_ordered_hashmap_free_ _cleanup_(ordered_hashmap_freep)
426

427
DEFINE_TRIVIAL_CLEANUP_FUNC(IteratedCache*, iterated_cache_free);
428

429
#define _cleanup_iterated_cache_free_ _cleanup_(iterated_cache_freep)
430

431
void hashmap_trim_pools(void);
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc