| 1 | /* |
| 2 | * Copyright 2009 Red Hat Inc., Durham, North Carolina. |
| 3 | * All Rights Reserved. |
| 4 | * |
| 5 | * This library is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU Lesser General Public |
| 7 | * License as published by the Free Software Foundation; either |
| 8 | * version 2.1 of the License, or (at your option) any later version. |
| 9 | * |
| 10 | * This library is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | * Lesser General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU Lesser General Public |
| 16 | * License along with this library; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | * |
| 19 | * Authors: |
| 20 | * Lukas Kuklinek <[email protected]> |
| 21 | */ |
| 22 | |
| 23 | #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:409:9`! |
| 24 | #include <config.h>cxx . . $ `<file>/build/config.h`/ |
| 25 | #endif |
| 26 | |
| 27 | #include <assert.h> |
| 28 | #include <string.h> |
| 29 | #include <stdio.h> |
| 30 | #include <stdarg.h> |
| 31 | |
| 32 | #include "list.h"cxx . . $ `<file>/src/common/list.h`/ |
| 33 | static inline boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! _oscap_iterator_has_more_internalcxx . . $ _oscap_iterator_has_more_internal(3f70fd89cdd07bed).(const struct oscap_iteratorcxx . . $ oscap_iterator# *it); |
| 34 | |
| 35 | struct oscap_listcxx . . $ oscap_list# *oscap_list_newcxx . . $ oscap_list_new(ea215f73c8361bff).(void) |
| 36 | { |
| 37 | struct oscap_listcxx . . $ oscap_list# *list = calloccxx . . $ calloc(63a7bf2941bfcd7a).(1, sizeof(struct oscap_listcxx . . $ oscap_list#)); |
| 38 | return list; |
| 39 | } |
| 40 | |
| 41 | void oscap_create_listscxx . . $ oscap_create_lists(ec4abf0a650ab9a0).(struct oscap_listcxx . . $ oscap_list# **first, ...) |
| 42 | { |
| 43 | va_listcxx . . $ va_list# ap; |
| 44 | va_startcxx . . $ `<external>/8105065126723003039/stdarg.h:50:9`!(ap, first); |
| 45 | for (struct oscap_listcxx . . $ oscap_list# **cur = first; cur != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; cur = va_argcxx . . $ `<external>/8105065126723003039/stdarg.h:53:9`!(ap, struct oscap_list **)) |
| 46 | *cur = oscap_list_newcxx . . $ oscap_list_new(ea215f73c8361bff).(); |
| 47 | va_endcxx . . $ `<external>/8105065126723003039/stdarg.h:52:9`!(ap); |
| 48 | } |
| 49 | |
| 50 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! oscap_list_addcxx . . $ oscap_list_add(97f28760a5cf7823).(struct oscap_listcxx . . $ oscap_list# * list, void *value) |
| 51 | { |
| 52 | __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(list); |
| 53 | if (value == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 54 | |
| 55 | struct oscap_list_itemcxx . . $ oscap_list_item# *item = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(struct oscap_list_itemcxx . . $ oscap_list_item#)); |
| 56 | item->nextcxx . . $ oscap_list_item#next. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 57 | item->datacxx . . $ oscap_list_item#data. = value; |
| 58 | ++list->itemcountcxx . . $ oscap_list#itemcount.; |
| 59 | |
| 60 | if (list->lastcxx . . $ oscap_list#last. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 61 | list->firstcxx . . $ oscap_list#first. = list->lastcxx . . $ oscap_list#last. = item; |
| 62 | else { |
| 63 | list->lastcxx . . $ oscap_list#last.->nextcxx . . $ oscap_list_item#next. = item; |
| 64 | list->lastcxx . . $ oscap_list#last. = item; |
| 65 | } |
| 66 | return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 67 | } |
| 68 | |
| 69 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! oscap_list_prependcxx . . $ oscap_list_prepend(97f28760a5cf7823).(struct oscap_listcxx . . $ oscap_list# * list, void *value) |
| 70 | { |
| 71 | __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(list); |
| 72 | if (value == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 73 | |
| 74 | struct oscap_list_itemcxx . . $ oscap_list_item# *item = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(struct oscap_list_itemcxx . . $ oscap_list_item#)); |
| 75 | item->nextcxx . . $ oscap_list_item#next. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 76 | item->datacxx . . $ oscap_list_item#data. = value; |
| 77 | ++list->itemcountcxx . . $ oscap_list#itemcount.; |
| 78 | |
| 79 | if (list->firstcxx . . $ oscap_list#first. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 80 | list->lastcxx . . $ oscap_list#last. = list->firstcxx . . $ oscap_list#first. = item; |
| 81 | } else { |
| 82 | item->nextcxx . . $ oscap_list_item#next. = list->firstcxx . . $ oscap_list#first.; |
| 83 | list->firstcxx . . $ oscap_list#first. = item; |
| 84 | } |
| 85 | return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 86 | } |
| 87 | |
| 88 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! oscap_list_pushcxx . . $ oscap_list_push(97f28760a5cf7823).(struct oscap_listcxx . . $ oscap_list# *list, void *value) |
| 89 | { |
| 90 | return oscap_list_addcxx . . $ oscap_list_add(97f28760a5cf7823).(list,value); |
| 91 | } |
| 92 | |
| 93 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! oscap_list_popcxx . . $ oscap_list_pop(8038dc059d248e3c).(struct oscap_listcxx . . $ oscap_list# *list, oscap_destruct_funccxx . . $ oscap_destruct_func# destructor) |
| 94 | { |
| 95 | if (list == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || list->firstcxx . . $ oscap_list#first. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 96 | struct oscap_list_itemcxx . . $ oscap_list_item# *cur = list->firstcxx . . $ oscap_list#first., *prev = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 97 | |
| 98 | while (cur != list->lastcxx . . $ oscap_list#last.) { |
| 99 | prev = cur; |
| 100 | cur = cur->nextcxx . . $ oscap_list_item#next.; |
| 101 | } |
| 102 | |
| 103 | if (destructor) destructor(cur->datacxx . . $ oscap_list_item#data.); |
| 104 | freecxx . . $ free(5d22bdacc48458e8).(cur); |
| 105 | |
| 106 | list->lastcxx . . $ oscap_list#last. = prev; |
| 107 | if (prev) prev->nextcxx . . $ oscap_list_item#next. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 108 | else list->firstcxx . . $ oscap_list#first. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 109 | |
| 110 | --list->itemcountcxx . . $ oscap_list#itemcount.; |
| 111 | |
| 112 | return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 113 | } |
| 114 | |
| 115 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! oscap_list_removecxx . . $ oscap_list_remove(7e6762e164fcba91).(struct oscap_listcxx . . $ oscap_list# *list, void *value, oscap_cmp_funccxx . . $ oscap_cmp_func# compare, oscap_destruct_funccxx . . $ oscap_destruct_func# destructor) |
| 116 | { |
| 117 | if (list == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || list->firstcxx . . $ oscap_list#first. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 118 | struct oscap_list_itemcxx . . $ oscap_list_item# *cur = list->firstcxx . . $ oscap_list#first., *prev = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 119 | |
| 120 | while (cur != list->lastcxx . . $ oscap_list#last. && !compare(cur->datacxx . . $ oscap_list_item#data., value)) { |
| 121 | prev = cur; |
| 122 | cur = cur->nextcxx . . $ oscap_list_item#next.; |
| 123 | } |
| 124 | |
| 125 | if (compare(cur->datacxx . . $ oscap_list_item#data., value)) { |
| 126 | if (prev) |
| 127 | prev->nextcxx . . $ oscap_list_item#next. = cur->nextcxx . . $ oscap_list_item#next.; |
| 128 | else |
| 129 | list->firstcxx . . $ oscap_list#first. = cur->nextcxx . . $ oscap_list_item#next.; |
| 130 | |
| 131 | if (cur == list->lastcxx . . $ oscap_list#last.) |
| 132 | list->lastcxx . . $ oscap_list#last. = prev; |
| 133 | |
| 134 | if (destructor) destructor(cur->datacxx . . $ oscap_list_item#data.); |
| 135 | freecxx . . $ free(5d22bdacc48458e8).(cur); |
| 136 | |
| 137 | --list->itemcountcxx . . $ oscap_list#itemcount.; |
| 138 | return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 139 | } |
| 140 | |
| 141 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 142 | } |
| 143 | |
| 144 | struct oscap_listcxx . . $ oscap_list# * oscap_list_clonecxx . . $ oscap_list_clone(7e3970b01307df8e).(const struct oscap_listcxx . . $ oscap_list# * list, oscap_clone_funccxx . . $ oscap_clone_func# cloner) |
| 145 | { |
| 146 | if (list == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 147 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 148 | |
| 149 | struct oscap_listcxx . . $ oscap_list# * copy = oscap_list_newcxx . . $ oscap_list_new(ea215f73c8361bff).(); |
| 150 | struct oscap_list_itemcxx . . $ oscap_list_item# * item; |
| 151 | |
| 152 | item = list->firstcxx . . $ oscap_list#first.; |
| 153 | while (item != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 154 | if (cloner) |
| 155 | oscap_list_addcxx . . $ oscap_list_add(97f28760a5cf7823).(copy, cloner(item->datacxx . . $ oscap_list_item#data.)); |
| 156 | else oscap_list_addcxx . . $ oscap_list_add(97f28760a5cf7823).(copy, item->datacxx . . $ oscap_list_item#data.); |
| 157 | item = item->nextcxx . . $ oscap_list_item#next.; |
| 158 | } |
| 159 | |
| 160 | return copy; |
| 161 | } |
| 162 | |
| 163 | struct oscap_listcxx . . $ oscap_list# *oscap_list_destructive_joincxx . . $ oscap_list_destructive_join(ff1de76ad37ec509).(struct oscap_listcxx . . $ oscap_list# *list1, struct oscap_listcxx . . $ oscap_list# *list2) |
| 164 | { |
| 165 | if (list1->firstcxx . . $ oscap_list#first. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 166 | list1->firstcxx . . $ oscap_list#first. = list2->firstcxx . . $ oscap_list#first.; |
| 167 | else list1->lastcxx . . $ oscap_list#last.->nextcxx . . $ oscap_list_item#next. = list2->firstcxx . . $ oscap_list#first.; |
| 168 | if (list2->lastcxx . . $ oscap_list#last. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) list1->lastcxx . . $ oscap_list#last. = list2->lastcxx . . $ oscap_list#last.; |
| 169 | list1->itemcountcxx . . $ oscap_list#itemcount. += list2->itemcountcxx . . $ oscap_list#itemcount.; |
| 170 | freecxx . . $ free(5d22bdacc48458e8).(list2); |
| 171 | return list1; |
| 172 | } |
| 173 | |
| 174 | int oscap_list_get_itemcountcxx . . $ oscap_list_get_itemcount(5b766af325364e37).(struct oscap_listcxx . . $ oscap_list# *list) |
| 175 | { |
| 176 | __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(list); |
| 177 | return list->itemcountcxx . . $ oscap_list#itemcount.; |
| 178 | } |
| 179 | |
| 180 | void oscap_list_freecxx . . $ oscap_list_free(e68e105c3900fcc1).(struct oscap_listcxx . . $ oscap_list# *list, oscap_destruct_funccxx . . $ oscap_destruct_func# destructor) |
| 181 | { |
| 182 | struct oscap_list_itemcxx . . $ oscap_list_item# *item, *to_del; |
| 183 | if (list) { |
| 184 | item = list->firstcxx . . $ oscap_list#first.; |
| 185 | while (item != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 186 | to_del = item; |
| 187 | item = item->nextcxx . . $ oscap_list_item#next.; |
| 188 | if (destructor) |
| 189 | destructor(to_del->datacxx . . $ oscap_list_item#data.); |
| 190 | freecxx . . $ free(5d22bdacc48458e8).(to_del); |
| 191 | } |
| 192 | freecxx . . $ free(5d22bdacc48458e8).(list); |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | void oscap_list_free0cxx . . $ oscap_list_free0(27ed2064e5aec1b1).(struct oscap_listcxx . . $ oscap_list# *list) |
| 197 | { |
| 198 | oscap_list_freecxx . . $ oscap_list_free(e68e105c3900fcc1).(list, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 199 | } |
| 200 | |
| 201 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! oscap_ptr_cmpcxx . . $ oscap_ptr_cmp(838b4d1787e4a177).(void *node1, void *node2) |
| 202 | { |
| 203 | return node1 == node2; |
| 204 | } |
| 205 | |
| 206 | void* oscap_list_findcxx . . $ oscap_list_find(56869e8d639c7a63).(struct oscap_listcxx . . $ oscap_list# *list, void *what, oscap_cmp_funccxx . . $ oscap_cmp_func# compare) |
| 207 | { |
| 208 | if (list == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 209 | if (compare == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) compare = oscap_ptr_cmpcxx . . $ oscap_ptr_cmp(838b4d1787e4a177).; |
| 210 | |
| 211 | struct oscap_iteratorcxx . . $ oscap_iterator# *it = oscap_iterator_newcxx . . $ oscap_iterator_new(f89fb456dfd589d7).(list); |
| 212 | |
| 213 | while (_oscap_iterator_has_more_internalcxx . . $ _oscap_iterator_has_more_internal(3f70fd89cdd07bed).(it)) { |
| 214 | void *item = oscap_iterator_nextcxx . . $ oscap_iterator_next(4c75051c806960eb).(it); |
| 215 | if (compare(item, what)) { |
| 216 | oscap_iterator_freecxx . . $ oscap_iterator_free(3cba44c1b7872358).(it); |
| 217 | return item; |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | oscap_iterator_freecxx . . $ oscap_iterator_free(3cba44c1b7872358).(it); |
| 222 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 223 | } |
| 224 | |
| 225 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! oscap_list_containscxx . . $ oscap_list_contains(810ee1985baa5ebe).(struct oscap_listcxx . . $ oscap_list# *list, void *what, oscap_cmp_funccxx . . $ oscap_cmp_func# compare) |
| 226 | { |
| 227 | return oscap_list_findcxx . . $ oscap_list_find(56869e8d639c7a63).(list, what, compare) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 228 | } |
| 229 | |
| 230 | void oscap_list_dumpcxx . . $ oscap_list_dump(df0831e7fcc09688).(struct oscap_listcxx . . $ oscap_list# *list, oscap_dump_funccxx . . $ oscap_dump_func# dumper, int depth) |
| 231 | { |
| 232 | if (list == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 233 | printfcxx . . $ printf(581fddd72a8db8fc).(" (NULL list)\n"); |
| 234 | return; |
| 235 | } |
| 236 | printfcxx . . $ printf(581fddd72a8db8fc).(" (list, %u item%s)\n", (unsigned)list->itemcountcxx . . $ oscap_list#itemcount., (list->itemcountcxx . . $ oscap_list#itemcount. == 1 ? "" : "s")); |
| 237 | struct oscap_list_itemcxx . . $ oscap_list_item# *item = list->firstcxx . . $ oscap_list#first.; |
| 238 | while (item) { |
| 239 | dumper(item->datacxx . . $ oscap_list_item#data., depth); |
| 240 | item = item->nextcxx . . $ oscap_list_item#next.; |
| 241 | } |
| 242 | } |
| 243 | |
| 244 | static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! oscap_iterator_no_filtercxx . . $ oscap_iterator_no_filter(838b4d1787e4a177).(void *foo, void *bar) |
| 245 | { |
| 246 | return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 247 | } |
| 248 | |
| 249 | static inline void oscap_iterator_find_nearestcxx . . $ oscap_iterator_find_nearest(3cba44c1b7872358).(struct oscap_iteratorcxx . . $ oscap_iterator# *it) |
| 250 | { |
| 251 | __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(it); |
| 252 | __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(it->list); |
| 253 | |
| 254 | do { |
| 255 | it->curcxx . . $ oscap_iterator#cur. = (it->curcxx . . $ oscap_iterator#cur. ? it->curcxx . . $ oscap_iterator#cur.->nextcxx . . $ oscap_list_item#next. : it->listcxx . . $ oscap_iterator#list.->firstcxx . . $ oscap_list#first.); |
| 256 | } while (it->curcxx . . $ oscap_iterator#cur. && !it->filtercxx . . $ oscap_iterator#filter.(it->curcxx . . $ oscap_iterator#cur.->datacxx . . $ oscap_list_item#data., it->user_datacxx . . $ oscap_iterator#user_data.) && _oscap_iterator_has_more_internalcxx . . $ _oscap_iterator_has_more_internal(3f70fd89cdd07bed).(it)); |
| 257 | } |
| 258 | |
| 259 | void *oscap_iterator_newcxx . . $ oscap_iterator_new(f89fb456dfd589d7).(struct oscap_listcxx . . $ oscap_list# *list) |
| 260 | { |
| 261 | struct oscap_iteratorcxx . . $ oscap_iterator# *it = calloccxx . . $ calloc(63a7bf2941bfcd7a).(1, sizeof(struct oscap_iteratorcxx . . $ oscap_iterator#)); |
| 262 | it->curcxx . . $ oscap_iterator#cur. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 263 | it->filtercxx . . $ oscap_iterator#filter. = oscap_iterator_no_filtercxx . . $ oscap_iterator_no_filter(838b4d1787e4a177).; |
| 264 | it->listcxx . . $ oscap_iterator#list. = list; |
| 265 | return it; |
| 266 | } |
| 267 | |
| 268 | void *oscap_iterator_new_filtercxx . . $ oscap_iterator_new_filter(412a5e5f37b98023).(struct oscap_listcxx . . $ oscap_list# *list, oscap_filter_funccxx . . $ oscap_filter_func# filter, void *user_data) |
| 269 | { |
| 270 | struct oscap_iteratorcxx . . $ oscap_iterator# *it = oscap_iterator_newcxx . . $ oscap_iterator_new(f89fb456dfd589d7).(list); |
| 271 | it->filtercxx . . $ oscap_iterator#filter. = filter; |
| 272 | it->user_datacxx . . $ oscap_iterator#user_data. = user_data; |
| 273 | return it; |
| 274 | } |
| 275 | |
| 276 | size_tcxx . . $ size_t# oscap_iterator_get_itemcountcxx . . $ oscap_iterator_get_itemcount(88013f75f0376f74).(const struct oscap_iteratorcxx . . $ oscap_iterator# * it) |
| 277 | { |
| 278 | __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(it); |
| 279 | return it->listcxx . . $ oscap_iterator#list.->itemcountcxx . . $ oscap_list#itemcount.; |
| 280 | } |
| 281 | |
| 282 | void *oscap_iterator_detachcxx . . $ oscap_iterator_detach(4c75051c806960eb).(struct oscap_iteratorcxx . . $ oscap_iterator# *it) |
| 283 | { |
| 284 | __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(it); |
| 285 | |
| 286 | if (!it->curcxx . . $ oscap_iterator#cur.) |
| 287 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 288 | |
| 289 | struct oscap_list_itemcxx . . $ oscap_list_item# *item = it->curcxx . . $ oscap_iterator#cur.; |
| 290 | void *value = item->datacxx . . $ oscap_list_item#data.; |
| 291 | |
| 292 | assertcxx . . $ `/usr/include/assert.h:50:10`!(it->list->first != NULL && it->list->last != NULL); |
| 293 | |
| 294 | if (it->listcxx . . $ oscap_iterator#list.->firstcxx . . $ oscap_list#first. == it->listcxx . . $ oscap_iterator#list.->lastcxx . . $ oscap_list#last.) { |
| 295 | assertcxx . . $ `/usr/include/assert.h:50:10`!(it->list->first == it->list->last); |
| 296 | assertcxx . . $ `/usr/include/assert.h:50:10`!(it->list->first == item); |
| 297 | it->listcxx . . $ oscap_iterator#list.->firstcxx . . $ oscap_list#first. = it->listcxx . . $ oscap_iterator#list.->lastcxx . . $ oscap_list#last. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 298 | it->curcxx . . $ oscap_iterator#cur. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 299 | } else if (item == it->listcxx . . $ oscap_iterator#list.->firstcxx . . $ oscap_list#first.) { |
| 300 | assertcxx . . $ `/usr/include/assert.h:50:10`!(it->list->first != it->list->last); |
| 301 | assertcxx . . $ `/usr/include/assert.h:50:10`!(item->next != NULL); |
| 302 | it->listcxx . . $ oscap_iterator#list.->firstcxx . . $ oscap_list#first. = item->nextcxx . . $ oscap_list_item#next.; |
| 303 | it->curcxx . . $ oscap_iterator#cur. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 304 | } else { |
| 305 | struct oscap_list_itemcxx . . $ oscap_list_item# *cur = it->listcxx . . $ oscap_iterator#list.->firstcxx . . $ oscap_list#first.; |
| 306 | while (cur->nextcxx . . $ oscap_list_item#next. != item) { |
| 307 | assertcxx . . $ `/usr/include/assert.h:50:10`!(cur->next != NULL); |
| 308 | cur = cur->nextcxx . . $ oscap_list_item#next.; |
| 309 | } |
| 310 | assertcxx . . $ `/usr/include/assert.h:50:10`!(cur->next == item); |
| 311 | cur->nextcxx . . $ oscap_list_item#next. = item->nextcxx . . $ oscap_list_item#next.; |
| 312 | if (item == it->listcxx . . $ oscap_iterator#list.->lastcxx . . $ oscap_list#last.) |
| 313 | it->listcxx . . $ oscap_iterator#list.->lastcxx . . $ oscap_list#last. = cur; |
| 314 | it->curcxx . . $ oscap_iterator#cur. = cur; |
| 315 | } |
| 316 | |
| 317 | freecxx . . $ free(5d22bdacc48458e8).(item); |
| 318 | --it->listcxx . . $ oscap_iterator#list.->itemcountcxx . . $ oscap_list#itemcount.; |
| 319 | return value; |
| 320 | } |
| 321 | |
| 322 | void oscap_iterator_freecxx . . $ oscap_iterator_free(3cba44c1b7872358).(struct oscap_iteratorcxx . . $ oscap_iterator# *it) |
| 323 | { |
| 324 | freecxx . . $ free(5d22bdacc48458e8).(it); |
| 325 | } |
| 326 | |
| 327 | void *oscap_iterator_nextcxx . . $ oscap_iterator_next(4c75051c806960eb).(struct oscap_iteratorcxx . . $ oscap_iterator# *it) |
| 328 | { |
| 329 | __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(it); |
| 330 | oscap_iterator_find_nearestcxx . . $ oscap_iterator_find_nearest(3cba44c1b7872358).(it); |
| 331 | return it->curcxx . . $ oscap_iterator#cur.->datacxx . . $ oscap_list_item#data.; |
| 332 | } |
| 333 | |
| 334 | static inline boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! _oscap_iterator_has_more_internalcxx . . $ _oscap_iterator_has_more_internal(3f70fd89cdd07bed).(const struct oscap_iteratorcxx . . $ oscap_iterator# *it) |
| 335 | { |
| 336 | return (!it->curcxx . . $ oscap_iterator#cur. && it->listcxx . . $ oscap_iterator#list.->firstcxx . . $ oscap_list#first.) || (it->curcxx . . $ oscap_iterator#cur. && it->curcxx . . $ oscap_iterator#cur.->nextcxx . . $ oscap_list_item#next.); |
| 337 | } |
| 338 | |
| 339 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! oscap_iterator_has_morecxx . . $ oscap_iterator_has_more(63b1de9a5adb9205).(struct oscap_iteratorcxx . . $ oscap_iterator# *it) |
| 340 | { |
| 341 | if (!it || !it->listcxx . . $ oscap_iterator#list. || !it->listcxx . . $ oscap_iterator#list.->firstcxx . . $ oscap_list#first.) |
| 342 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 343 | if (it->curcxx . . $ oscap_iterator#cur. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 344 | if (it->filtercxx . . $ oscap_iterator#filter.(it->listcxx . . $ oscap_iterator#list.->firstcxx . . $ oscap_list#first.->datacxx . . $ oscap_list_item#data., it->user_datacxx . . $ oscap_iterator#user_data.)) |
| 345 | return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 346 | else |
| 347 | it->curcxx . . $ oscap_iterator#cur. = it->listcxx . . $ oscap_iterator#list.->firstcxx . . $ oscap_list#first.; |
| 348 | } |
| 349 | while (it->curcxx . . $ oscap_iterator#cur.->nextcxx . . $ oscap_list_item#next. && !it->filtercxx . . $ oscap_iterator#filter.(it->curcxx . . $ oscap_iterator#cur.->nextcxx . . $ oscap_list_item#next.->datacxx . . $ oscap_list_item#data., it->user_datacxx . . $ oscap_iterator#user_data.)) |
| 350 | it->curcxx . . $ oscap_iterator#cur. = it->curcxx . . $ oscap_iterator#cur.->nextcxx . . $ oscap_list_item#next.; |
| 351 | return it->curcxx . . $ oscap_iterator#cur.->nextcxx . . $ oscap_list_item#next. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 352 | } |
| 353 | |
| 354 | void oscap_iterator_resetcxx . . $ oscap_iterator_reset(3cba44c1b7872358).(struct oscap_iteratorcxx . . $ oscap_iterator# * it) |
| 355 | { |
| 356 | it->curcxx . . $ oscap_iterator#cur. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 357 | } |
| 358 | |
| 359 | struct oscap_stringlistcxx . . $ oscap_stringlist# *oscap_stringlist_clonecxx . . $ oscap_stringlist_clone(3b3c67b595f43f9d).(struct oscap_stringlistcxx . . $ oscap_stringlist# *list) |
| 360 | { |
| 361 | void *clone = oscap_list_newcxx . . $ oscap_list_new(ea215f73c8361bff).(); // oscap_stringlist (or oscap_list) |
| 362 | OSCAP_FOR_STRcxx . . $ `src/common/list.h:163:9`!(str, oscap_stringlist_get_strings(list)) |
| 363 | oscap_list_addcxx . . $ oscap_list_add(97f28760a5cf7823).(clone, oscap_strdupcxx . . $ oscap_strdup(a8b8e32347182212).(str)); |
| 364 | return clone; |
| 365 | } |
| 366 | |
| 367 | struct oscap_string_iteratorcxx . . $ oscap_string_iterator# *oscap_stringlist_get_stringscxx . . $ oscap_stringlist_get_strings(13be827fcd32d2b9).(const struct oscap_stringlistcxx . . $ oscap_stringlist#* list) |
| 368 | { |
| 369 | return oscap_iterator_newcxx . . $ oscap_iterator_new(f89fb456dfd589d7).((struct oscap_listcxx . . $ oscap_list# *) list); |
| 370 | } |
| 371 | |
| 372 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! oscap_stringlist_add_stringcxx . . $ oscap_stringlist_add_string(80c12aaea9c014af).(struct oscap_stringlistcxx . . $ oscap_stringlist#* list, const char *str) |
| 373 | { |
| 374 | return oscap_list_addcxx . . $ oscap_list_add(97f28760a5cf7823).((struct oscap_listcxx . . $ oscap_list# *) list, oscap_strdupcxx . . $ oscap_strdup(a8b8e32347182212).(str)); |
| 375 | } |
| 376 | |
| 377 | struct oscap_stringlistcxx . . $ oscap_stringlist# * oscap_stringlist_newcxx . . $ oscap_stringlist_new(22a991cfbca9a1c).(void) |
| 378 | { |
| 379 | return (struct oscap_stringlistcxx . . $ oscap_stringlist# *) oscap_list_newcxx . . $ oscap_list_new(ea215f73c8361bff).(); |
| 380 | } |
| 381 | |
| 382 | void oscap_stringlist_freecxx . . $ oscap_stringlist_free(7df8e35292df4dfb).(struct oscap_stringlistcxx . . $ oscap_stringlist# *list) |
| 383 | { |
| 384 | oscap_list_freecxx . . $ oscap_list_free(e68e105c3900fcc1).((struct oscap_listcxx . . $ oscap_list# *) list, freecxx . . $ free(5d22bdacc48458e8).); |
| 385 | } |
| 386 | |
| 387 | OSCAP_ITERATOR_GEN_Tcxx . . $ `src/common/util.h:122:9`!(const char *, oscap_string) |
| 388 | OSCAP_ITERATOR_REMOVE_Tcxx . . $ `src/common/util.h:125:9`!(const char *, oscap_string, free) |
| 389 | OSCAP_ITERATOR_GENcxx . . $ `src/common/util.h:123:9`!(oscap_stringlist) |
| 390 | OSCAP_ITERATOR_REMOVEcxx . . $ `src/common/util.h:127:9`!(oscap_stringlist, oscap_stringlist_free) |
| 391 | /*OSCAP_ITERATOR_RESET(oscap_string)*/ |
| 392 | |
| 393 | |
| 394 | #define OSCAP_DEFAULT_HSIZEcxx . . $ `src/common/list.c:394:9`! 389 |
| 395 | static inline unsigned int oscap_htable_hashcxx . . $ oscap_htable_hash(b323a3098472c9f4).(const char *str, size_tcxx . . $ size_t# htable_size) |
| 396 | { |
| 397 | unsigned h = 0; |
| 398 | unsigned char *p; |
| 399 | for (p = (unsigned char *)str; *p != '\0'; p++) |
| 400 | h = (97 * h) + *p; |
| 401 | return h % htable_size; |
| 402 | } |
| 403 | |
| 404 | struct oscap_htablecxx . . $ oscap_htable# *oscap_htable_new1cxx . . $ oscap_htable_new1(65089fcacd1ec7ff).(oscap_compare_funccxx . . $ oscap_compare_func# cmp, size_tcxx . . $ size_t# hsize) |
| 405 | { |
| 406 | struct oscap_htablecxx . . $ oscap_htable# *t; |
| 407 | |
| 408 | assertcxx . . $ `/usr/include/assert.h:50:10`!(hsize > 0); |
| 409 | |
| 410 | t = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(struct oscap_htablecxx . . $ oscap_htable#)); |
| 411 | if (t == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 412 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 413 | t->hsizecxx . . $ oscap_htable#hsize. = hsize; |
| 414 | t->itemcountcxx . . $ oscap_htable#itemcount. = 0; |
| 415 | t->tablecxx . . $ oscap_htable#table. = calloccxx . . $ calloc(63a7bf2941bfcd7a).(hsize, sizeof(struct oscap_htable_itemcxx . . $ oscap_htable_item# *)); |
| 416 | if (t->tablecxx . . $ oscap_htable#table. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 417 | freecxx . . $ free(5d22bdacc48458e8).(t); |
| 418 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 419 | } |
| 420 | t->cmpcxx . . $ oscap_htable#cmp. = cmp; |
| 421 | return t; |
| 422 | } |
| 423 | |
| 424 | struct oscap_htablecxx . . $ oscap_htable# * oscap_htable_clonecxx . . $ oscap_htable_clone(c459a691cacbd47f).(const struct oscap_htablecxx . . $ oscap_htable# * table, oscap_clone_funccxx . . $ oscap_clone_func# cloner) |
| 425 | { |
| 426 | struct oscap_htablecxx . . $ oscap_htable# *t = oscap_htable_newcxx . . $ oscap_htable_new(3c1cb2b6f390ad38).(); |
| 427 | if (t == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 428 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 429 | |
| 430 | for (size_tcxx . . $ size_t# i = 0; i < table->hsizecxx . . $ oscap_htable#hsize.; ++i) { |
| 431 | struct oscap_htable_itemcxx . . $ oscap_htable_item# *item = table->tablecxx . . $ oscap_htable#table.[i]; |
| 432 | while (item != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 433 | oscap_htable_addcxx . . $ oscap_htable_add(d9abe78f59fa00eb).(t, item->keycxx . . $ oscap_htable_item#key., (void *) cloner(item->valuecxx . . $ oscap_htable_item#value.)); |
| 434 | item = item->nextcxx . . $ oscap_htable_item#next.; |
| 435 | } |
| 436 | } |
| 437 | |
| 438 | return t; |
| 439 | } |
| 440 | |
| 441 | static int oscap_htable_cmpcxx . . $ oscap_htable_cmp(5ae29d726ae57f88).(const char *s1, const char *s2) |
| 442 | { |
| 443 | if (s1 == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 444 | return -1; |
| 445 | if (s2 == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 446 | return 1; |
| 447 | return strcmpcxx . . $ strcmp(5ae29d726ae57f88).(s1, s2); |
| 448 | } |
| 449 | |
| 450 | struct oscap_htablecxx . . $ oscap_htable# *oscap_htable_newcxx . . $ oscap_htable_new(3c1cb2b6f390ad38).(void) |
| 451 | { |
| 452 | return oscap_htable_new1cxx . . $ oscap_htable_new1(65089fcacd1ec7ff).(oscap_htable_cmpcxx . . $ oscap_htable_cmp(5ae29d726ae57f88)., OSCAP_DEFAULT_HSIZEcxx . . $ `src/common/list.c:394:9`!); |
| 453 | } |
| 454 | |
| 455 | static struct oscap_htable_itemcxx . . $ oscap_htable_item# *oscap_htable_lookupcxx . . $ oscap_htable_lookup(dcde31b67687ea66).(struct oscap_htablecxx . . $ oscap_htable# *htable, const char *key) |
| 456 | { |
| 457 | __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(htable); |
| 458 | if (key == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 459 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 460 | unsigned int hashcode = oscap_htable_hashcxx . . $ oscap_htable_hash(b323a3098472c9f4).(key, htable->hsizecxx . . $ oscap_htable#hsize.); |
| 461 | struct oscap_htable_itemcxx . . $ oscap_htable_item# *htitem = htable->tablecxx . . $ oscap_htable#table.[hashcode]; |
| 462 | while (htitem != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 463 | if (htable->cmpcxx . . $ oscap_htable#cmp.(htitem->keycxx . . $ oscap_htable_item#key., key) == 0) |
| 464 | return htitem; |
| 465 | htitem = htitem->nextcxx . . $ oscap_htable_item#next.; |
| 466 | } |
| 467 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 468 | } |
| 469 | |
| 470 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! oscap_htable_addcxx . . $ oscap_htable_add(d9abe78f59fa00eb).(struct oscap_htablecxx . . $ oscap_htable# * htable, const char *key, void *item) |
| 471 | { |
| 472 | __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(htable); |
| 473 | /* |
| 474 | unsigned int hashcode = oscap_htable_hash(key, htable->hsize); |
| 475 | struct oscap_htable_item* htitem = htable->table[hashcode]; |
| 476 | while(htitem != NULL) |
| 477 | { |
| 478 | if( (*(htable->cmp))(htitem->key, key) == 0) return false; |
| 479 | if(htitem->next == NULL) break; |
| 480 | htitem = htitem->next; |
| 481 | } |
| 482 | // htitem points to the last item |
| 483 | */ |
| 484 | if (oscap_htable_lookupcxx . . $ oscap_htable_lookup(dcde31b67687ea66).(htable, key) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 485 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 486 | unsigned int hashcode = oscap_htable_hashcxx . . $ oscap_htable_hash(b323a3098472c9f4).(key, htable->hsizecxx . . $ oscap_htable#hsize.); |
| 487 | struct oscap_htable_itemcxx . . $ oscap_htable_item# *newhtitem; |
| 488 | newhtitem = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(struct oscap_htable_itemcxx . . $ oscap_htable_item#)); |
| 489 | newhtitem->keycxx . . $ oscap_htable_item#key. = oscap_strdupcxx . . $ oscap_strdup(a8b8e32347182212).(key); |
| 490 | newhtitem->valuecxx . . $ oscap_htable_item#value. = item; |
| 491 | newhtitem->nextcxx . . $ oscap_htable_item#next. = htable->tablecxx . . $ oscap_htable#table.[hashcode]; |
| 492 | htable->tablecxx . . $ oscap_htable#table.[hashcode] = newhtitem; |
| 493 | htable->itemcountcxx . . $ oscap_htable#itemcount.++; |
| 494 | return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 495 | } |
| 496 | |
| 497 | void *oscap_htable_detachcxx . . $ oscap_htable_detach(f5c7e8ff6c970cd3).(struct oscap_htablecxx . . $ oscap_htable# *htable, const char *key) |
| 498 | { |
| 499 | struct oscap_htable_itemcxx . . $ oscap_htable_item# *htitem = oscap_htable_lookupcxx . . $ oscap_htable_lookup(dcde31b67687ea66).(htable, key); |
| 500 | if (htitem) { |
| 501 | void *val = htitem->valuecxx . . $ oscap_htable_item#value.; |
| 502 | freecxx . . $ free(5d22bdacc48458e8).(htitem->keycxx . . $ oscap_htable_item#key.); |
| 503 | htitem->keycxx . . $ oscap_htable_item#key. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 504 | htitem->valuecxx . . $ oscap_htable_item#value. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 505 | htable->itemcountcxx . . $ oscap_htable#itemcount.--; |
| 506 | return val; |
| 507 | } |
| 508 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 509 | } |
| 510 | |
| 511 | void *oscap_htable_getcxx . . $ oscap_htable_get(f5c7e8ff6c970cd3).(struct oscap_htablecxx . . $ oscap_htable# *htable, const char *key) |
| 512 | { |
| 513 | __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(htable); |
| 514 | struct oscap_htable_itemcxx . . $ oscap_htable_item# *htitem = oscap_htable_lookupcxx . . $ oscap_htable_lookup(dcde31b67687ea66).(htable, key); |
| 515 | return htitem ? htitem->valuecxx . . $ oscap_htable_item#value. : NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 516 | } |
| 517 | |
| 518 | size_tcxx . . $ size_t# oscap_htable_itemcountcxx . . $ oscap_htable_itemcount(74d87088304a4a23).(struct oscap_htablecxx . . $ oscap_htable# *htable) |
| 519 | { |
| 520 | return htable->itemcountcxx . . $ oscap_htable#itemcount.; |
| 521 | } |
| 522 | |
| 523 | void oscap_print_depthcxx . . $ oscap_print_depth(d4f767463ce0a6b3).(int); |
| 524 | |
| 525 | void oscap_htable_dumpcxx . . $ oscap_htable_dump(93d367da24ec0c3e).(struct oscap_htablecxx . . $ oscap_htable# *htable, oscap_dump_funccxx . . $ oscap_dump_func# dumper, int depth) |
| 526 | { |
| 527 | if (htable == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 528 | printfcxx . . $ printf(581fddd72a8db8fc).(" (NULL hash table)\n"); |
| 529 | return; |
| 530 | } |
| 531 | printfcxx . . $ printf(581fddd72a8db8fc).(" (hash table, %u item%s)\n", (unsigned)htable->itemcountcxx . . $ oscap_htable#itemcount., (htable->itemcountcxx . . $ oscap_htable#itemcount. == 1 ? "" : "s")); |
| 532 | int i; |
| 533 | for (i = 0; i < (int)htable->hsizecxx . . $ oscap_htable#hsize.; ++i) { |
| 534 | struct oscap_htable_itemcxx . . $ oscap_htable_item# *item = htable->tablecxx . . $ oscap_htable#table.[i]; |
| 535 | while (item) { |
| 536 | oscap_print_depthcxx . . $ oscap_print_depth(d4f767463ce0a6b3).(depth); |
| 537 | printfcxx . . $ printf(581fddd72a8db8fc).("'%s':\n", item->keycxx . . $ oscap_htable_item#key.); |
| 538 | dumper(item->valuecxx . . $ oscap_htable_item#value., depth + 1); |
| 539 | item = item->nextcxx . . $ oscap_htable_item#next.; |
| 540 | } |
| 541 | } |
| 542 | } |
| 543 | |
| 544 | void oscap_htable_freecxx . . $ oscap_htable_free(efa5da5da5d523d).(struct oscap_htablecxx . . $ oscap_htable# *htable, oscap_destruct_funccxx . . $ oscap_destruct_func# destructor) |
| 545 | { |
| 546 | if (htable) { |
| 547 | size_tcxx . . $ size_t# ht; |
| 548 | struct oscap_htable_itemcxx . . $ oscap_htable_item# *cur, *next; |
| 549 | |
| 550 | for (ht = 0; ht < htable->hsizecxx . . $ oscap_htable#hsize.; ++ht) { |
| 551 | cur = htable->tablecxx . . $ oscap_htable#table.[ht]; |
| 552 | while (cur) { |
| 553 | next = cur->nextcxx . . $ oscap_htable_item#next.; |
| 554 | freecxx . . $ free(5d22bdacc48458e8).(cur->keycxx . . $ oscap_htable_item#key.); |
| 555 | if (destructor) |
| 556 | destructor(cur->valuecxx . . $ oscap_htable_item#value.); |
| 557 | freecxx . . $ free(5d22bdacc48458e8).(cur); |
| 558 | cur = next; |
| 559 | } |
| 560 | } |
| 561 | |
| 562 | freecxx . . $ free(5d22bdacc48458e8).(htable->tablecxx . . $ oscap_htable#table.); |
| 563 | freecxx . . $ free(5d22bdacc48458e8).(htable); |
| 564 | } |
| 565 | } |
| 566 | |
| 567 | void oscap_htable_free0cxx . . $ oscap_htable_free0(dbd8f9d05ba37fd5).(struct oscap_htablecxx . . $ oscap_htable# *htable) |
| 568 | { |
| 569 | oscap_htable_freecxx . . $ oscap_htable_free(efa5da5da5d523d).(htable, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 570 | } |
| 571 | |
| 572 | struct oscap_htable_iteratorcxx . . $ oscap_htable_iterator# { |
| 573 | struct oscap_htablecxx . . $ oscap_htable# *htablecxx . . $ oscap_htable_iterator#htable.; // Table we iterate through |
| 574 | struct oscap_htable_itemcxx . . $ oscap_htable_item# *curcxx . . $ oscap_htable_iterator#cur.; // The current item |
| 575 | size_tcxx . . $ size_t# hposcxx . . $ oscap_htable_iterator#hpos.; // Line on which we are now |
| 576 | }; |
| 577 | |
| 578 | struct oscap_htable_iteratorcxx . . $ oscap_htable_iterator# * |
| 579 | oscap_htable_iterator_newcxx . . $ oscap_htable_iterator_new(81743c99830972e7).(struct oscap_htablecxx . . $ oscap_htable# *htable) |
| 580 | { |
| 581 | struct oscap_htable_iteratorcxx . . $ oscap_htable_iterator# *hit = calloccxx . . $ calloc(63a7bf2941bfcd7a).(1, sizeof(struct oscap_htable_iteratorcxx . . $ oscap_htable_iterator#)); |
| 582 | hit->htablecxx . . $ oscap_htable_iterator#htable. = htable; |
| 583 | hit->curcxx . . $ oscap_htable_iterator#cur. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 584 | hit->hposcxx . . $ oscap_htable_iterator#hpos. = 0; |
| 585 | return hit; |
| 586 | } |
| 587 | |
| 588 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! |
| 589 | oscap_htable_iterator_has_morecxx . . $ oscap_htable_iterator_has_more(eba4198ab3388c55).(struct oscap_htable_iteratorcxx . . $ oscap_htable_iterator# *hit) |
| 590 | { |
| 591 | __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(hit); |
| 592 | if (hit->htablecxx . . $ oscap_htable_iterator#htable. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 593 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 594 | size_tcxx . . $ size_t# i = hit->hposcxx . . $ oscap_htable_iterator#hpos.; |
| 595 | if (hit->curcxx . . $ oscap_htable_iterator#cur. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 596 | if (hit->curcxx . . $ oscap_htable_iterator#cur.->nextcxx . . $ oscap_htable_item#next. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 597 | return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 598 | if (i + 1 >= hit->htablecxx . . $ oscap_htable_iterator#htable.->hsizecxx . . $ oscap_htable#hsize.) |
| 599 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 600 | i++; |
| 601 | } |
| 602 | for (; i < hit->htablecxx . . $ oscap_htable_iterator#htable.->hsizecxx . . $ oscap_htable#hsize.; i++) { |
| 603 | if (hit->htablecxx . . $ oscap_htable_iterator#htable.->tablecxx . . $ oscap_htable#table.[i] == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 604 | continue; |
| 605 | if (i != hit->hposcxx . . $ oscap_htable_iterator#hpos.) |
| 606 | hit->hposcxx . . $ oscap_htable_iterator#hpos. = i - 1; |
| 607 | return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 608 | } |
| 609 | hit->hposcxx . . $ oscap_htable_iterator#hpos. = i; |
| 610 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 611 | } |
| 612 | |
| 613 | const struct oscap_htable_itemcxx . . $ oscap_htable_item# * |
| 614 | oscap_htable_iterator_nextcxx . . $ oscap_htable_iterator_next(98c5256d433bc020).(struct oscap_htable_iteratorcxx . . $ oscap_htable_iterator# *hit) |
| 615 | { |
| 616 | __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(hit); |
| 617 | if (hit->curcxx . . $ oscap_htable_iterator#cur. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 618 | if (hit->curcxx . . $ oscap_htable_iterator#cur.->nextcxx . . $ oscap_htable_item#next. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 619 | hit->curcxx . . $ oscap_htable_iterator#cur. = hit->curcxx . . $ oscap_htable_iterator#cur.->nextcxx . . $ oscap_htable_item#next.; |
| 620 | return hit->curcxx . . $ oscap_htable_iterator#cur.; |
| 621 | } |
| 622 | if (hit->hposcxx . . $ oscap_htable_iterator#hpos. + 1 >= hit->htablecxx . . $ oscap_htable_iterator#htable.->hsizecxx . . $ oscap_htable#hsize.) { |
| 623 | assertcxx . . $ `/usr/include/assert.h:50:10`!(false); |
| 624 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 625 | } |
| 626 | hit->hposcxx . . $ oscap_htable_iterator#hpos.++; |
| 627 | } |
| 628 | for (; hit->hposcxx . . $ oscap_htable_iterator#hpos. < hit->htablecxx . . $ oscap_htable_iterator#htable.->hsizecxx . . $ oscap_htable#hsize.; hit->hposcxx . . $ oscap_htable_iterator#hpos.++) { |
| 629 | if (hit->htablecxx . . $ oscap_htable_iterator#htable.->tablecxx . . $ oscap_htable#table.[hit->hposcxx . . $ oscap_htable_iterator#hpos.] == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 630 | continue; |
| 631 | hit->curcxx . . $ oscap_htable_iterator#cur. = hit->htablecxx . . $ oscap_htable_iterator#htable.->tablecxx . . $ oscap_htable#table.[hit->hposcxx . . $ oscap_htable_iterator#hpos.]; |
| 632 | return hit->curcxx . . $ oscap_htable_iterator#cur.; |
| 633 | } |
| 634 | assertcxx . . $ `/usr/include/assert.h:50:10`!(false); // no more item found |
| 635 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 636 | } |
| 637 | |
| 638 | const char * |
| 639 | oscap_htable_iterator_next_keycxx . . $ oscap_htable_iterator_next_key(952d27177769fc02).(struct oscap_htable_iteratorcxx . . $ oscap_htable_iterator# *hit) |
| 640 | { |
| 641 | const struct oscap_htable_itemcxx . . $ oscap_htable_item# *item = oscap_htable_iterator_nextcxx . . $ oscap_htable_iterator_next(98c5256d433bc020).(hit); |
| 642 | return (item == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) ? NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! : item->keycxx . . $ oscap_htable_item#key.; |
| 643 | } |
| 644 | |
| 645 | void * |
| 646 | oscap_htable_iterator_next_valuecxx . . $ oscap_htable_iterator_next_value(4e1156670e4376db).(struct oscap_htable_iteratorcxx . . $ oscap_htable_iterator# *hit) |
| 647 | { |
| 648 | const struct oscap_htable_itemcxx . . $ oscap_htable_item# *item = oscap_htable_iterator_nextcxx . . $ oscap_htable_iterator_next(98c5256d433bc020).(hit); |
| 649 | return (item == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) ? NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! : item->valuecxx . . $ oscap_htable_item#value.; |
| 650 | } |
| 651 | |
| 652 | void oscap_htable_iterator_next_kvcxx . . $ oscap_htable_iterator_next_kv(6fdd88671b26854e).(struct oscap_htable_iteratorcxx . . $ oscap_htable_iterator# *hit, const char **key, void **value) |
| 653 | { |
| 654 | const struct oscap_htable_itemcxx . . $ oscap_htable_item# *item = oscap_htable_iterator_nextcxx . . $ oscap_htable_iterator_next(98c5256d433bc020).(hit); |
| 655 | if (item == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 656 | return; |
| 657 | |
| 658 | *key = item->keycxx . . $ oscap_htable_item#key.; |
| 659 | *value = item->valuecxx . . $ oscap_htable_item#value.; |
| 660 | } |
| 661 | |
| 662 | void |
| 663 | oscap_htable_iterator_resetcxx . . $ oscap_htable_iterator_reset(e07ea5562ff119bd).(struct oscap_htable_iteratorcxx . . $ oscap_htable_iterator# *hit) |
| 664 | { |
| 665 | __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(hit); |
| 666 | hit->curcxx . . $ oscap_htable_iterator#cur. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 667 | hit->hposcxx . . $ oscap_htable_iterator#hpos. = 0; |
| 668 | } |
| 669 | |
| 670 | void |
| 671 | oscap_htable_iterator_freecxx . . $ oscap_htable_iterator_free(e07ea5562ff119bd).(struct oscap_htable_iteratorcxx . . $ oscap_htable_iterator# *hit) |
| 672 | { |
| 673 | freecxx . . $ free(5d22bdacc48458e8).(hit); |
| 674 | } |
| 675 | |
| 676 | void oscap_print_depthcxx . . $ oscap_print_depth(d4f767463ce0a6b3).(int depth) |
| 677 | { |
| 678 | while (depth--) |
| 679 | printfcxx . . $ printf(581fddd72a8db8fc).(" "); |
| 680 | } |