| 1 | /* |
| 2 | * Copyright 2010 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 | * "Daniel Kopecek" <[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 <errno.h> |
| 28 | #include <stdlib.h> |
| 29 | #include "rbt_common.h"cxx . . $ `<file>/src/OVAL/probes/SEAP/generic/rbt/rbt_common.h`/ |
| 30 | #include "rbt_i32.h"cxx . . $ `<file>/src/OVAL/probes/SEAP/generic/rbt/rbt_i32.h`/ |
| 31 | |
| 32 | static struct rbt_nodecxx . . $ rbt_node# *rbt_i32_node_alloccxx . . $ rbt_i32_node_alloc(f8688e5b52751a64).(void) |
| 33 | { |
| 34 | struct rbt_nodecxx . . $ rbt_node# *n = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 35 | #ifndef OS_WINDOWS |
| 36 | if (posix_memaligncxx . . $ posix_memalign(e974a8a87fa206f3).((void **)(void *)(&n), sizeof(void *), |
| 37 | sizeof (struct rbt_nodecxx . . $ rbt_node#) + sizeof (struct rbt_i32_nodecxx . . $ rbt_i32_node#)) != 0) |
| 38 | { |
| 39 | abortcxx . . $ abort(8df32a62017fbbf6). (); |
| 40 | } |
| 41 | #else |
| 42 | // https://msdn.microsoft.com/en-us/library/8z34s9c6.aspx |
| 43 | n = _aligned_malloc(sizeof (struct rbt_node) + sizeof (struct rbt_i32_node), sizeof(void *)); |
| 44 | #endif |
| 45 | n->_chldcxx . . $ rbt_node#_chld.[0] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 46 | n->_chldcxx . . $ rbt_node#_chld.[1] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 47 | |
| 48 | return(n); |
| 49 | } |
| 50 | |
| 51 | static void rbt_i32_node_freecxx . . $ rbt_i32_node_free(ea57ab5850a9e42).(struct rbt_nodecxx . . $ rbt_node# *n) |
| 52 | { |
| 53 | if (n != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 54 | { |
| 55 | #ifndef OS_WINDOWS |
| 56 | freecxx . . $ free(5d22bdacc48458e8).(rbt_node_ptrcxx . . $ rbt_node_ptr(a7124440667b6d30).(n)); |
| 57 | #else |
| 58 | // using free for memory allocated through _aligned_malloc is illegal |
| 59 | // rbt_i32.c -> rbt_i32_node_alloc |
| 60 | // https://msdn.microsoft.com/en-us/library/8z34s9c6.aspx |
| 61 | _aligned_free(rbt_node_ptr(n)); |
| 62 | #endif |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | rbt_tcxx . . $ rbt_t# *rbt_i32_newcxx . . $ rbt_i32_new(557e4aca7c153cb). (void) |
| 67 | { |
| 68 | return rbt_newcxx . . $ rbt_new(14dbdc406d46a6e3). (RBT_I32KEYcxx . . $ RBT_I32KEY.); |
| 69 | } |
| 70 | |
| 71 | void rbt_i32_freecxx . . $ rbt_i32_free(c2e6369c3901716e). (rbt_tcxx . . $ rbt_t# *rbt) |
| 72 | { |
| 73 | rbt_freecxx . . $ rbt_free(bee5363cd6a39661).(rbt, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 74 | } |
| 75 | |
| 76 | void rbt_i32_free_cbcxx . . $ rbt_i32_free_cb(bb6fef081ac885b3). (rbt_tcxx . . $ rbt_t# *rbt, void (*callback)(rbt_i32_node_tcxx . . $ rbt_i32_node_t# *)) |
| 77 | { |
| 78 | rbt_freecxx . . $ rbt_free(bee5363cd6a39661).(rbt, (void(*)(void *))callback); |
| 79 | } |
| 80 | |
| 81 | /* |
| 82 | * Add new entry to the tree. If `coll' is not NULL and there is |
| 83 | * already an entry with the same key (i.e. a collision), then |
| 84 | * place the old data pointer at `*coll' and update it to the |
| 85 | * new data pointer. Otherwise, if `coll' is NULL and there is a |
| 86 | * collision, then an error is returned and no modification of |
| 87 | * the tree is made. |
| 88 | * |
| 89 | * @param rbt pointer to the tree |
| 90 | * @param key key |
| 91 | * @param data data pointer |
| 92 | * @param coll where to store the data pointer from an colliding entry |
| 93 | */ |
| 94 | int rbt_i32_addcxx . . $ rbt_i32_add(3215e2e734e57b31).(rbt_tcxx . . $ rbt_t# *rbt, int32_tcxx . . $ int32_t# key, void *data, void **coll) |
| 95 | { |
| 96 | struct rbt_nodecxx . . $ rbt_node# fake; |
| 97 | struct rbt_nodecxx . . $ rbt_node# *h[4]; |
| 98 | register uint8_tcxx . . $ uint8_t# dvec; |
| 99 | register int32_tcxx . . $ int32_t# n_key, u_key; |
| 100 | |
| 101 | u_key = key; |
| 102 | rbt_wlockcxx . . $ rbt_wlock(5b7afdec655f93de).(rbt); |
| 103 | |
| 104 | /* |
| 105 | * Fake node |
| 106 | */ |
| 107 | fake._chldcxx . . $ rbt_node#_chld.[RBT_NODE_SLcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:71:9`!] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 108 | fake._chldcxx . . $ rbt_node#_chld.[RBT_NODE_SRcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:72:9`!] = rbt->rootcxx . . $ rbt#root.; |
| 109 | rbt_node_setcolorcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:83:9`!(&fake, RBT_NODE_CBcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:69:9`!); |
| 110 | |
| 111 | /* |
| 112 | * Prepare node history stack & direction history vector |
| 113 | */ |
| 114 | h[3] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 115 | h[2] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 116 | h[1] = &fake; |
| 117 | h[0] = rbt->rootcxx . . $ rbt#root.; |
| 118 | dvec = RBT_NODE_SRcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:72:9`!; |
| 119 | |
| 120 | for (;;) { |
| 121 | if (rbt_node_ptrcxx . . $ rbt_node_ptr(a7124440667b6d30).(h[0]) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 122 | /* |
| 123 | * Allocate new node aligned to sizeof(void *) bytes. |
| 124 | * On most systems, malloc already returns aligned |
| 125 | * memory but we want to ensure that its aligned using |
| 126 | * posix_memalign(3). |
| 127 | */ |
| 128 | h[0] = rbt_i32_node_alloccxx . . $ rbt_i32_node_alloc(f8688e5b52751a64). (); |
| 129 | |
| 130 | rbt_i32_nodecxx . . $ rbt_i32_node(b0ced95b14661b6c).(h[0])->keycxx . . $ rbt_i32_node#key. = key; |
| 131 | rbt_i32_nodecxx . . $ rbt_i32_node(b0ced95b14661b6c).(h[0])->datacxx . . $ rbt_i32_node#data. = data; |
| 132 | |
| 133 | /* |
| 134 | * Set the new node as the child of the last node we've |
| 135 | * visited. The last direction is the lowest bit of the |
| 136 | * direction history vector. |
| 137 | */ |
| 138 | rbt_node_setptrcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:81:9`!(rbt_node_ptr(h[1])->_chld[dvec & 1], h[0]); |
| 139 | rbt_node_setcolorcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:83:9`!(h[0], RBT_NODE_CRcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:70:9`!); |
| 140 | |
| 141 | /* |
| 142 | * Since we are inserting a new red node, we need to fix |
| 143 | * a red violation if the parent of the new node is red. |
| 144 | */ |
| 145 | if (rbt_node_getcolorcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:94:9`!(h[1]) == RBT_NODE_CRcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:70:9`!) { |
| 146 | rbt_redfixcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:112:9`!(h, dvec, rbt_node_ptr(h[3])->_chld[(dvec >> 2) & 1]); |
| 147 | } |
| 148 | |
| 149 | /* |
| 150 | * Update root node and color it black |
| 151 | */ |
| 152 | rbt->rootcxx . . $ rbt#root. = fake._chldcxx . . $ rbt_node#_chld.[RBT_NODE_SRcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:72:9`!]; |
| 153 | rbt_node_setcolorcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:83:9`!(rbt->root, RBT_NODE_CBcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:69:9`!); |
| 154 | |
| 155 | /* |
| 156 | * Update node counter |
| 157 | */ |
| 158 | ++(rbt->sizecxx . . $ rbt#size.); |
| 159 | |
| 160 | break; |
| 161 | } else if (rbt_node_getcolorcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:94:9`!(rbt_node_ptr(h[0])->_chld[0]) == RBT_NODE_CRcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:70:9`! && |
| 162 | rbt_node_getcolorcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:94:9`!(rbt_node_ptr(h[0])->_chld[1]) == RBT_NODE_CRcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:70:9`!) |
| 163 | { |
| 164 | /* |
| 165 | * Color switch |
| 166 | */ |
| 167 | rbt_node_setcolorcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:83:9`!(h[0], RBT_NODE_CRcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:70:9`!); |
| 168 | rbt_node_setcolorcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:83:9`!(rbt_node_ptr(h[0])->_chld[0], RBT_NODE_CBcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:69:9`!); |
| 169 | rbt_node_setcolorcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:83:9`!(rbt_node_ptr(h[0])->_chld[1], RBT_NODE_CBcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:69:9`!); |
| 170 | |
| 171 | /* |
| 172 | * Fix red violation |
| 173 | */ |
| 174 | if (rbt_node_getcolorcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:94:9`!(h[1]) == RBT_NODE_CRcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:70:9`!) { |
| 175 | rbt_redfixcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:112:9`!(h, dvec, rbt_node_ptr(h[3])->_chld[(dvec >> 2) & 1]); |
| 176 | } |
| 177 | } else if (rbt_node_getcolorcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:94:9`!(h[0]) == RBT_NODE_CRcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:70:9`! && |
| 178 | rbt_node_getcolorcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:94:9`!(h[1]) == RBT_NODE_CRcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:70:9`!) |
| 179 | { |
| 180 | /* |
| 181 | * Fix red violation |
| 182 | */ |
| 183 | rbt_redfixcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:112:9`!(h, dvec, rbt_node_ptr(h[3])->_chld[(dvec >> 2)&1]); |
| 184 | } |
| 185 | |
| 186 | n_key = rbt_i32_nodecxx . . $ rbt_i32_node(b0ced95b14661b6c).(h[0])->keycxx . . $ rbt_i32_node#key.; |
| 187 | |
| 188 | if (u_key < n_key) { |
| 189 | rbt_hpush4cxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:97:9`!(h, rbt_node_ptr(h[0])->_chld[RBT_NODE_SLcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:71:9`!]); |
| 190 | dvec = (dvec << 1) | RBT_NODE_SLcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:71:9`!; |
| 191 | } else if (u_key > n_key) { |
| 192 | rbt_hpush4cxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:97:9`!(h, rbt_node_ptr(h[0])->_chld[RBT_NODE_SRcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:72:9`!]); |
| 193 | dvec = (dvec << 1) | RBT_NODE_SRcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:72:9`!; |
| 194 | } else { |
| 195 | int r; |
| 196 | |
| 197 | if (coll != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 198 | *coll = rbt_i32_nodecxx . . $ rbt_i32_node(b0ced95b14661b6c).(h[0])->datacxx . . $ rbt_i32_node#data.; |
| 199 | rbt_i32_nodecxx . . $ rbt_i32_node(b0ced95b14661b6c).(h[0])->datacxx . . $ rbt_i32_node#data. = data; |
| 200 | r = 0; |
| 201 | } else |
| 202 | r = 1; |
| 203 | |
| 204 | /* |
| 205 | * Update root node and color it black |
| 206 | */ |
| 207 | rbt->rootcxx . . $ rbt#root. = fake._chldcxx . . $ rbt_node#_chld.[RBT_NODE_SRcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:72:9`!]; |
| 208 | rbt_node_setcolorcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:83:9`!(rbt->root, RBT_NODE_CBcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:69:9`!); |
| 209 | |
| 210 | rbt_wunlockcxx . . $ rbt_wunlock(c2e6369c3901716e).(rbt); |
| 211 | return (r); |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | rbt_wunlockcxx . . $ rbt_wunlock(c2e6369c3901716e).(rbt); |
| 216 | return (0); |
| 217 | } |
| 218 | |
| 219 | void *rbt_i32_repcxx . . $ rbt_i32_rep(81d8678dd25067a8).(rbt_tcxx . . $ rbt_t# *rbt, int32_tcxx . . $ int32_t# key, void *data) |
| 220 | { |
| 221 | return (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 222 | } |
| 223 | |
| 224 | int rbt_i32_delcxx . . $ rbt_i32_del(fbdfcf5a3c6c46ec).(rbt_tcxx . . $ rbt_t# *rbt, int32_tcxx . . $ int32_t# key, void **n) |
| 225 | { |
| 226 | struct rbt_nodecxx . . $ rbt_node# fake, *save; |
| 227 | struct rbt_nodecxx . . $ rbt_node# *h[4]; |
| 228 | register uint8_tcxx . . $ uint8_t# dvec; |
| 229 | register int32_tcxx . . $ int32_t# n_key, u_key; |
| 230 | |
| 231 | save = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 232 | u_key = key; |
| 233 | |
| 234 | rbt_wlockcxx . . $ rbt_wlock(5b7afdec655f93de).(rbt); |
| 235 | |
| 236 | if (rbt->sizecxx . . $ rbt#size. == 0) { |
| 237 | rbt_wunlockcxx . . $ rbt_wunlock(c2e6369c3901716e).(rbt); |
| 238 | return (1); |
| 239 | } |
| 240 | |
| 241 | if (rbt_node_ptrcxx . . $ rbt_node_ptr(a7124440667b6d30).(rbt->rootcxx . . $ rbt#root.) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 242 | return -1; |
| 243 | } |
| 244 | |
| 245 | /* |
| 246 | * Fake node |
| 247 | */ |
| 248 | fake._chldcxx . . $ rbt_node#_chld.[RBT_NODE_SLcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:71:9`!] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 249 | fake._chldcxx . . $ rbt_node#_chld.[RBT_NODE_SRcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:72:9`!] = rbt->rootcxx . . $ rbt#root.; |
| 250 | rbt_node_setcolorcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:83:9`!(&fake, RBT_NODE_CBcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:69:9`!); |
| 251 | |
| 252 | /* |
| 253 | * Prepare node history stack & direction history vector |
| 254 | */ |
| 255 | h[2] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 256 | h[1] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 257 | h[0] = &fake; |
| 258 | dvec = RBT_NODE_SRcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:72:9`!; |
| 259 | |
| 260 | for (;;) { |
| 261 | if (rbt_node_ptrcxx . . $ rbt_node_ptr(a7124440667b6d30).(rbt_node_ptrcxx . . $ rbt_node_ptr(a7124440667b6d30).(h[0])->_chldcxx . . $ rbt_node#_chld.[dvec & 1]) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 262 | break; |
| 263 | |
| 264 | rbt_hpush4cxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:97:9`!(h, rbt_node_ptr(h[0])->_chld[dvec & 1]); |
| 265 | n_key = rbt_i32_nodecxx . . $ rbt_i32_node(b0ced95b14661b6c).(h[0])->keycxx . . $ rbt_i32_node#key.; |
| 266 | |
| 267 | if (u_key < n_key) { |
| 268 | dvec = (dvec << 1) | RBT_NODE_SLcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:71:9`!; |
| 269 | } else if (u_key > n_key) { |
| 270 | dvec = (dvec << 1) | RBT_NODE_SRcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:72:9`!; |
| 271 | } else { |
| 272 | save = rbt_node_ptrcxx . . $ rbt_node_ptr(a7124440667b6d30).(h[0]); |
| 273 | dvec = (dvec << 1) | RBT_NODE_SLcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:71:9`!; |
| 274 | } |
| 275 | |
| 276 | if (rbt_node_getcolorcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:94:9`!(h[0]) == RBT_NODE_CBcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:69:9`! && |
| 277 | rbt_node_getcolorcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:94:9`!(rbt_node_ptr(h[0])->_chld[dvec & 1]) == RBT_NODE_CBcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:69:9`!) |
| 278 | { |
| 279 | if (rbt_node_getcolorcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:94:9`!(rbt_node_ptr(h[0])->_chld[!(dvec & 1)]) == RBT_NODE_CRcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:70:9`!) { |
| 280 | switch(dvec & 1) { |
| 281 | case RBT_NODE_SRcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:72:9`!: |
| 282 | rbt_node_setptrcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:81:9`!(rbt_node_ptr(h[1])->_chld[(dvec >> 1) & 1], |
| 283 | rbt_node_rotate_R(h[0])); |
| 284 | break; |
| 285 | case RBT_NODE_SLcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:71:9`!: |
| 286 | rbt_node_setptrcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:81:9`!(rbt_node_ptr(h[1])->_chld[(dvec >> 1) & 1], |
| 287 | rbt_node_rotate_L(h[0])); |
| 288 | break; |
| 289 | } |
| 290 | |
| 291 | h[1] = rbt_node_ptrcxx . . $ rbt_node_ptr(a7124440667b6d30).(h[1])->_chldcxx . . $ rbt_node#_chld.[(dvec >> 1) & 1]; |
| 292 | } else { |
| 293 | register struct rbt_nodecxx . . $ rbt_node# *s; |
| 294 | |
| 295 | s = rbt_node_ptrcxx . . $ rbt_node_ptr(a7124440667b6d30).(rbt_node_ptrcxx . . $ rbt_node_ptr(a7124440667b6d30).(h[1])->_chldcxx . . $ rbt_node#_chld.[!((dvec >> 1) & 1)]); |
| 296 | |
| 297 | if (s != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 298 | if (rbt_node_getcolorcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:94:9`!(s->_chld[0]) == RBT_NODE_CBcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:69:9`! && |
| 299 | rbt_node_getcolorcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:94:9`!(s->_chld[1]) == RBT_NODE_CBcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:69:9`!) |
| 300 | { |
| 301 | rbt_node_setcolorcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:83:9`!(h[0], RBT_NODE_CRcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:70:9`!); |
| 302 | rbt_node_setcolorcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:83:9`!(h[1], RBT_NODE_CBcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:69:9`!); |
| 303 | rbt_node_setcolorcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:83:9`!(s, RBT_NODE_CRcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:70:9`!); |
| 304 | } else { |
| 305 | register uint8_tcxx . . $ uint8_t# d = rbt_node_ptrcxx . . $ rbt_node_ptr(a7124440667b6d30).(rbt_node_ptrcxx . . $ rbt_node_ptr(a7124440667b6d30).(h[2])->_chldcxx . . $ rbt_node#_chld.[RBT_NODE_SRcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:72:9`!]) == rbt_node_ptrcxx . . $ rbt_node_ptr(a7124440667b6d30).(h[1]); |
| 306 | |
| 307 | if (rbt_node_getcolorcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:94:9`!(s->_chld[(dvec >> 1) & 1]) == RBT_NODE_CRcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:70:9`!) { |
| 308 | switch((dvec >> 1) & 1) { |
| 309 | case RBT_NODE_SRcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:72:9`!: |
| 310 | rbt_node_setptrcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:81:9`!(rbt_node_ptr(h[2])->_chld[d], |
| 311 | rbt_node_rotate_RL(h[1])); |
| 312 | break; |
| 313 | case RBT_NODE_SLcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:71:9`!: |
| 314 | rbt_node_setptrcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:81:9`!(rbt_node_ptr(h[2])->_chld[d], |
| 315 | rbt_node_rotate_LR(h[1])); |
| 316 | break; |
| 317 | } |
| 318 | } else if (rbt_node_getcolorcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:94:9`!(s->_chld[!((dvec >> 1) & 1)]) == RBT_NODE_CRcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:70:9`!) { |
| 319 | switch((dvec >> 1) & 1) { |
| 320 | case RBT_NODE_SRcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:72:9`!: |
| 321 | rbt_node_setptrcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:81:9`!(rbt_node_ptr(h[2])->_chld[d], |
| 322 | rbt_node_rotate_R(h[1])); |
| 323 | break; |
| 324 | case RBT_NODE_SLcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:71:9`!: |
| 325 | rbt_node_setptrcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:81:9`!(rbt_node_ptr(h[2])->_chld[d], |
| 326 | rbt_node_rotate_L(h[1])); |
| 327 | break; |
| 328 | } |
| 329 | } |
| 330 | |
| 331 | s = rbt_node_ptrcxx . . $ rbt_node_ptr(a7124440667b6d30).(rbt_node_ptrcxx . . $ rbt_node_ptr(a7124440667b6d30).(h[2])->_chldcxx . . $ rbt_node#_chld.[d]); |
| 332 | |
| 333 | rbt_node_setcolorcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:83:9`!(h[0], RBT_NODE_CRcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:70:9`!); |
| 334 | rbt_node_setcolorcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:83:9`!(s, RBT_NODE_CRcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:70:9`!); |
| 335 | rbt_node_setcolorcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:83:9`!(s->_chld[0], RBT_NODE_CBcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:69:9`!); |
| 336 | rbt_node_setcolorcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:83:9`!(s->_chld[1], RBT_NODE_CBcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:69:9`!); |
| 337 | } |
| 338 | } |
| 339 | } |
| 340 | } |
| 341 | } |
| 342 | |
| 343 | if (save != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 344 | h[0] = rbt_node_ptrcxx . . $ rbt_node_ptr(a7124440667b6d30).(h[0]); |
| 345 | /* |
| 346 | * The node color of the node that will be delete is always |
| 347 | * red in case the node is not the root node. |
| 348 | */ |
| 349 | if (rbt_node_ptrcxx . . $ rbt_node_ptr(a7124440667b6d30).(fake._chldcxx . . $ rbt_node#_chld.[RBT_NODE_SRcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:72:9`!]) != h[0] |
| 350 | && rbt_node_getcolorcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:94:9`!(h[0]) != RBT_NODE_CRcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:70:9`!) { |
| 351 | return -1; |
| 352 | } |
| 353 | if (n != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 354 | *n = rbt_i32_nodecxx . . $ rbt_i32_node(b0ced95b14661b6c).(save)->datacxx . . $ rbt_i32_node#data.; |
| 355 | |
| 356 | rbt_i32_nodecxx . . $ rbt_i32_node(b0ced95b14661b6c).(save)->datacxx . . $ rbt_i32_node#data. = rbt_i32_nodecxx . . $ rbt_i32_node(b0ced95b14661b6c).(h[0])->datacxx . . $ rbt_i32_node#data.; |
| 357 | rbt_i32_nodecxx . . $ rbt_i32_node(b0ced95b14661b6c).(save)->keycxx . . $ rbt_i32_node#key. = rbt_i32_nodecxx . . $ rbt_i32_node(b0ced95b14661b6c).(h[0])->keycxx . . $ rbt_i32_node#key.; |
| 358 | |
| 359 | dvec = rbt_node_ptrcxx . . $ rbt_node_ptr(a7124440667b6d30).(rbt_node_ptrcxx . . $ rbt_node_ptr(a7124440667b6d30).(h[1])->_chldcxx . . $ rbt_node#_chld.[1]) == h[0]; |
| 360 | |
| 361 | if (rbt_node_ptrcxx . . $ rbt_node_ptr(a7124440667b6d30).(h[0]->_chldcxx . . $ rbt_node#_chld.[RBT_NODE_SRcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:72:9`!]) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 362 | rbt_node_setptrcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:81:9`!(rbt_node_ptr(h[1])->_chld[dvec], h[0]->_chld[RBT_NODE_SLcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:71:9`!]); |
| 363 | } else { |
| 364 | rbt_node_setptrcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:81:9`!(rbt_node_ptr(h[1])->_chld[dvec], h[0]->_chld[RBT_NODE_SRcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:72:9`!]); |
| 365 | } |
| 366 | |
| 367 | /* |
| 368 | * Free memory used by the deleted node and decrement |
| 369 | * the node counter. |
| 370 | */ |
| 371 | rbt_i32_node_freecxx . . $ rbt_i32_node_free(ea57ab5850a9e42).(h[0]); |
| 372 | --(rbt->sizecxx . . $ rbt#size.); |
| 373 | } |
| 374 | |
| 375 | /* |
| 376 | * Update root node and color it black and unlock the tree. |
| 377 | */ |
| 378 | rbt->rootcxx . . $ rbt#root. = fake._chldcxx . . $ rbt_node#_chld.[RBT_NODE_SRcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:72:9`!]; |
| 379 | rbt_node_setcolorcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:83:9`!(rbt->root, RBT_NODE_CBcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:69:9`!); |
| 380 | rbt_wunlockcxx . . $ rbt_wunlock(c2e6369c3901716e).(rbt); |
| 381 | |
| 382 | return (save == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ? 1 : 0); |
| 383 | } |
| 384 | |
| 385 | int rbt_i32_getcxx . . $ rbt_i32_get(fbdfcf5a3c6c46ec).(rbt_tcxx . . $ rbt_t# *rbt, int32_tcxx . . $ int32_t# key, void **data) |
| 386 | { |
| 387 | int r; |
| 388 | register struct rbt_nodecxx . . $ rbt_node# *n; |
| 389 | register int32_tcxx . . $ int32_t# u_key, n_key; |
| 390 | |
| 391 | u_key = key; |
| 392 | r = -1; |
| 393 | rbt_rlockcxx . . $ rbt_rlock(5b7afdec655f93de).(rbt); |
| 394 | n = rbt_node_ptrcxx . . $ rbt_node_ptr(a7124440667b6d30).(rbt->rootcxx . . $ rbt#root.); |
| 395 | |
| 396 | while (n != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 397 | n_key = rbt_i32_nodecxx . . $ rbt_i32_node(b0ced95b14661b6c).(n)->keycxx . . $ rbt_i32_node#key.; |
| 398 | |
| 399 | if (u_key < n_key) |
| 400 | n = rbt_node_ptrcxx . . $ rbt_node_ptr(a7124440667b6d30).(n->_chldcxx . . $ rbt_node#_chld.[RBT_NODE_SLcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:71:9`!]); |
| 401 | else if (u_key > n_key) |
| 402 | n = rbt_node_ptrcxx . . $ rbt_node_ptr(a7124440667b6d30).(n->_chldcxx . . $ rbt_node#_chld.[RBT_NODE_SRcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:72:9`!]); |
| 403 | else { |
| 404 | r = 0; |
| 405 | *data = rbt_i32_nodecxx . . $ rbt_i32_node(b0ced95b14661b6c).(n)->datacxx . . $ rbt_i32_node#data.; |
| 406 | break; |
| 407 | } |
| 408 | } |
| 409 | |
| 410 | rbt_runlockcxx . . $ rbt_runlock(c2e6369c3901716e).(rbt); |
| 411 | return (r); |
| 412 | } |
| 413 | |
| 414 | int rbt_i32_walk_preordercxx . . $ rbt_i32_walk_preorder(f66f2a39a434aaed).(rbt_tcxx . . $ rbt_t# *rbt, int (*callback)(rbt_i32_node_tcxx . . $ rbt_i32_node_t# *), rbt_walk_tcxx . . $ rbt_walk_t# flags) |
| 415 | { |
| 416 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = ENOSYScxx . . $ `<external>/17922322188510340118/errno.h:18:9`!; |
| 417 | return (-1); |
| 418 | } |
| 419 | |
| 420 | int rbt_i32_walk_inordercxx . . $ rbt_i32_walk_inorder(f66f2a39a434aaed).(rbt_tcxx . . $ rbt_t# *rbt, int (*callback)(rbt_i32_node_tcxx . . $ rbt_i32_node_t# *), rbt_walk_tcxx . . $ rbt_walk_t# flags) |
| 421 | { |
| 422 | return rbt_walk_inordercxx . . $ rbt_walk_inorder(c23f1c7969ddfc49).(rbt, (int(*)(void *))callback, flags); |
| 423 | } |
| 424 | |
| 425 | int rbt_i32_walk_postordercxx . . $ rbt_i32_walk_postorder(f66f2a39a434aaed).(rbt_tcxx . . $ rbt_t# *rbt, int (*callback)(rbt_i32_node_tcxx . . $ rbt_i32_node_t# *), rbt_walk_tcxx . . $ rbt_walk_t# flags) |
| 426 | { |
| 427 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = ENOSYScxx . . $ `<external>/17922322188510340118/errno.h:18:9`!; |
| 428 | return (-1); |
| 429 | } |
| 430 | |
| 431 | int rbt_i32_walk_levelordercxx . . $ rbt_i32_walk_levelorder(f66f2a39a434aaed).(rbt_tcxx . . $ rbt_t# *rbt, int (*callback)(rbt_i32_node_tcxx . . $ rbt_i32_node_t# *), rbt_walk_tcxx . . $ rbt_walk_t# flags) |
| 432 | { |
| 433 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = ENOSYScxx . . $ `<external>/17922322188510340118/errno.h:18:9`!; |
| 434 | return (-1); |
| 435 | } |
| 436 | |
| 437 | int rbt_i32_walkcxx . . $ rbt_i32_walk(fb0a1dfd7fad1473).(rbt_tcxx . . $ rbt_t# *rbt, rbt_walk_tcxx . . $ rbt_walk_t# type, int (*callback)(rbt_i32_node_tcxx . . $ rbt_i32_node_t# *)) |
| 438 | { |
| 439 | if (rbt == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || callback == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 440 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = EINVALcxx . . $ `<external>/8987895939074593727/errno-base.h:26:9`!; |
| 441 | return -1; |
| 442 | } |
| 443 | |
| 444 | switch (type & RBT_WALK_TYPEMASKcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:57:9`!) { |
| 445 | case RBT_WALK_PREORDERcxx . . $ RBT_WALK_PREORDER.: return rbt_i32_walk_preordercxx . . $ rbt_i32_walk_preorder(f66f2a39a434aaed).(rbt, callback, type); |
| 446 | case RBT_WALK_INORDERcxx . . $ RBT_WALK_INORDER.: return rbt_i32_walk_inordercxx . . $ rbt_i32_walk_inorder(f66f2a39a434aaed).(rbt, callback, type); |
| 447 | case RBT_WALK_POSTORDERcxx . . $ RBT_WALK_POSTORDER.: return rbt_i32_walk_postordercxx . . $ rbt_i32_walk_postorder(f66f2a39a434aaed).(rbt, callback, type); |
| 448 | case RBT_WALK_LEVELORDERcxx . . $ RBT_WALK_LEVELORDER.: return rbt_i32_walk_levelordercxx . . $ rbt_i32_walk_levelorder(f66f2a39a434aaed).(rbt, callback, type); |
| 449 | } |
| 450 | |
| 451 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = EINVALcxx . . $ `<external>/8987895939074593727/errno-base.h:26:9`!; |
| 452 | return (-1); |
| 453 | } |
| 454 | |
| 455 | size_t rbt_i32_sizecxx . . $ rbt_i32_size(6ae908cc234686bf).(rbt_tcxx . . $ rbt_t# *rbt) |
| 456 | { |
| 457 | return rbt_sizecxx . . $ rbt_size(6ae908cc234686bf).(rbt); |
| 458 | } |