Debian Codegraph @

src/OVAL/probes/SEAP/generic/rbt/rbt_str.c

raw symbols SCIP
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 <string.h>
28 #include <stdlib.h>
29 #include <errno.h>
30
31 #include "rbt_common.h"cxx . . $ `<file>/src/OVAL/probes/SEAP/generic/rbt/rbt_common.h`/
32 #include "rbt_str.h"cxx . . $ `<file>/src/OVAL/probes/SEAP/generic/rbt/rbt_str.h`/
33
34 static struct rbt_nodecxx . . $ rbt_node# *rbt_str_node_alloccxx . . $ rbt_str_node_alloc(f8688e5b52751a64).(void)
35 {
36 struct rbt_nodecxx . . $ rbt_node# *n = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
37
38 #ifndef OS_WINDOWS
39 if (posix_memaligncxx . . $ posix_memalign(e974a8a87fa206f3).((void **)(void *)(&n), sizeof(void *),
40 sizeof (struct rbt_nodecxx . . $ rbt_node#) + sizeof (struct rbt_str_nodecxx . . $ rbt_str_node#)) != 0)
41 {
42 abortcxx . . $ abort(8df32a62017fbbf6). ();
43 }
44 #else
45 // https://msdn.microsoft.com/en-us/library/8z34s9c6.aspx
46 n = _aligned_malloc(sizeof (struct rbt_node) + sizeof (struct rbt_str_node), sizeof(void *));
47 #endif
48
49 n->_chldcxx . . $ rbt_node#_chld.[0] = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
50 n->_chldcxx . . $ rbt_node#_chld.[1] = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
51
52 return(n);
53 }
54
55 static void rbt_str_node_freecxx . . $ rbt_str_node_free(ea57ab5850a9e42).(struct rbt_nodecxx . . $ rbt_node# *n)
56 {
57 if (n != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)
58 freecxx . . $ free(5d22bdacc48458e8).(rbt_node_ptrcxx . . $ rbt_node_ptr(a7124440667b6d30).(n));
59 }
60
61 rbt_tcxx . . $ rbt_t# *rbt_str_newcxx . . $ rbt_str_new(557e4aca7c153cb). (void)
62 {
63 return rbt_newcxx . . $ rbt_new(14dbdc406d46a6e3). (RBT_STRKEYcxx . . $ RBT_STRKEY.);
64 }
65
66 static void rbt_str_free_callbackcxx . . $ rbt_str_free_callback(bd95e63a1880cd3a).(struct rbt_str_nodecxx . . $ rbt_str_node# *n)
67 {
68 freecxx . . $ free(5d22bdacc48458e8).(n->keycxx . . $ rbt_str_node#key.);
69 /* node memory is freed by rbt_free */
70 }
71
72 void rbt_str_freecxx . . $ rbt_str_free(c2e6369c3901716e). (rbt_tcxx . . $ rbt_t# *rbt)
73 {
74 rbt_freecxx . . $ rbt_free(bee5363cd6a39661).(rbt, (void(*)(void *))&rbt_str_free_callbackcxx . . $ rbt_str_free_callback(bd95e63a1880cd3a).);
75 }
76
77 void rbt_str_free_cbcxx . . $ rbt_str_free_cb(d6c6edd7b040d8d5). (rbt_tcxx . . $ rbt_t# *rbt, void (*callback)(struct rbt_str_nodecxx . . $ rbt_str_node# *))
78 {
79 rbt_freecxx . . $ rbt_free(bee5363cd6a39661).(rbt, (void(*)(void *))callback);
80 }
81
82 void rbt_str_free_cb2cxx . . $ rbt_str_free_cb2(57a8905ddba3f9a3). (rbt_tcxx . . $ rbt_t# *rbt, void (*callback)(struct rbt_str_nodecxx . . $ rbt_str_node# *, void *user), void *user)
83 {
84 rbt_free2cxx . . $ rbt_free2(d2d9e6d8aa181e03).(rbt, (void(*)(void *, void *))callback, user);
85 }
86
87 int rbt_str_addcxx . . $ rbt_str_add(d471093ac4c699c2).(rbt_tcxx . . $ rbt_t# *rbt, char *key, void *data)
88 {
89 struct rbt_nodecxx . . $ rbt_node# fake;
90 struct rbt_nodecxx . . $ rbt_node# *h[4];
91 register uint8_tcxx . . $ uint8_t# dvec;
92 register char *n_key, *u_key;
93 register int cmp;
94
95 u_key = key;
96 rbt_wlockcxx . . $ rbt_wlock(5b7afdec655f93de).(rbt);
97
98 /*
99 * Fake node
100 */
101 fake._chldcxx . . $ rbt_node#_chld.[RBT_NODE_SLcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:71:9`!] = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
102 fake._chldcxx . . $ rbt_node#_chld.[RBT_NODE_SRcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:72:9`!] = rbt->rootcxx . . $ rbt#root.;
103 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`!);
104
105 /*
106 * Prepare node history stack & direction history vector
107 */
108 h[3] = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
109 h[2] = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
110 h[1] = &fake;
111 h[0] = rbt->rootcxx . . $ rbt#root.;
112 dvec = RBT_NODE_SRcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:72:9`!;
113
114 for (;;) {
115 if (rbt_node_ptrcxx . . $ rbt_node_ptr(a7124440667b6d30).(h[0]) == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
116 /*
117 * Allocate new node aligned to sizeof(void *) bytes.
118 * On most systems, malloc already returns aligned
119 * memory but we want to ensure that its aligned using
120 * posix_memalign(3).
121 */
122 h[0] = rbt_str_node_alloccxx . . $ rbt_str_node_alloc(f8688e5b52751a64). ();
123
124 rbt_str_nodecxx . . $ rbt_str_node(c08d81df1cfaabdf).(h[0])->keycxx . . $ rbt_str_node#key. = key;
125 rbt_str_nodecxx . . $ rbt_str_node(c08d81df1cfaabdf).(h[0])->datacxx . . $ rbt_str_node#data. = data;
126
127 /*
128 * Set the new node as the child of the last node we've
129 * visited. The last direction is the lowest bit of the
130 * direction history vector.
131 */
132 rbt_node_setptrcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:81:9`!(rbt_node_ptr(h[1])->_chld[dvec & 1], h[0]);
133 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`!);
134
135 /*
136 * Since we are inserting a new red node, we need to fix
137 * a red violation if the parent of the new node is red.
138 */
139 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`!) {
140 rbt_redfixcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:112:9`!(h, dvec, rbt_node_ptr(h[3])->_chld[(dvec >> 2) & 1]);
141 }
142
143 /*
144 * Update root node and color it black
145 */
146 rbt->rootcxx . . $ rbt#root. = fake._chldcxx . . $ rbt_node#_chld.[RBT_NODE_SRcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:72:9`!];
147 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`!);
148
149 /*
150 * Update node counter
151 */
152 ++(rbt->sizecxx . . $ rbt#size.);
153
154 break;
155 } 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`! &&
156 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`!)
157 {
158 /*
159 * Color switch
160 */
161 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`!);
162 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`!);
163 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`!);
164
165 /*
166 * Fix red violation
167 */
168 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`!) {
169 rbt_redfixcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:112:9`!(h, dvec, rbt_node_ptr(h[3])->_chld[(dvec >> 2) & 1]);
170 }
171 } 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`! &&
172 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`!)
173 {
174 /*
175 * Fix red violation
176 */
177 rbt_redfixcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:112:9`!(h, dvec, rbt_node_ptr(h[3])->_chld[(dvec >> 2)&1]);
178 }
179
180 n_key = rbt_str_nodecxx . . $ rbt_str_node(c08d81df1cfaabdf).(h[0])->keycxx . . $ rbt_str_node#key.;
181 cmp = strcmpcxx . . $ strcmp(5ae29d726ae57f88).(u_key, n_key);
182
183 if (cmp < 0) {
184 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`!]);
185 dvec = (dvec << 1) | RBT_NODE_SLcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:71:9`!;
186 } else if (cmp > 0) {
187 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`!]);
188 dvec = (dvec << 1) | RBT_NODE_SRcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:72:9`!;
189 } else {
190 /*
191 * Update root node and color it black
192 */
193 rbt->rootcxx . . $ rbt#root. = fake._chldcxx . . $ rbt_node#_chld.[RBT_NODE_SRcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:72:9`!];
194 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`!);
195
196 rbt_wunlockcxx . . $ rbt_wunlock(c2e6369c3901716e).(rbt);
197 return (1);
198 }
199 }
200
201 rbt_wunlockcxx . . $ rbt_wunlock(c2e6369c3901716e).(rbt);
202 return (0);
203 }
204
205 void *rbt_str_repcxx . . $ rbt_str_rep(c77a0ebda171103a).(rbt_tcxx . . $ rbt_t# *rbt, const char *key, void *data)
206 {
207 return (NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
208 }
209
210 int rbt_str_delcxx . . $ rbt_str_del(3cd4f904f7b02e6c).(rbt_tcxx . . $ rbt_t# *rbt, const char *key, void **n)
211 {
212 struct rbt_nodecxx . . $ rbt_node# fake, *save;
213 struct rbt_nodecxx . . $ rbt_node# *h[4];
214 register uint8_tcxx . . $ uint8_t# dvec;
215 register char *n_key, *u_key;
216 register int cmp;
217
218 save = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
219 u_key = (char *)key;
220
221 rbt_wlockcxx . . $ rbt_wlock(5b7afdec655f93de).(rbt);
222
223 if (rbt->sizecxx . . $ rbt#size. == 0) {
224 rbt_wunlockcxx . . $ rbt_wunlock(c2e6369c3901716e).(rbt);
225 return (1);
226 }
227
228 if (rbt_node_ptrcxx . . $ rbt_node_ptr(a7124440667b6d30).(rbt->rootcxx . . $ rbt#root.) == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
229 return -1;
230 }
231
232 /*
233 * Fake node
234 */
235 fake._chldcxx . . $ rbt_node#_chld.[RBT_NODE_SLcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:71:9`!] = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
236 fake._chldcxx . . $ rbt_node#_chld.[RBT_NODE_SRcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:72:9`!] = rbt->rootcxx . . $ rbt#root.;
237 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`!);
238
239 /*
240 * Prepare node history stack & direction history vector
241 */
242 h[2] = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
243 h[1] = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
244 h[0] = &fake;
245 dvec = RBT_NODE_SRcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:72:9`!;
246
247 for (;;) {
248 if (rbt_node_ptrcxx . . $ rbt_node_ptr(a7124440667b6d30).(rbt_node_ptrcxx . . $ rbt_node_ptr(a7124440667b6d30).(h[0])->_chldcxx . . $ rbt_node#_chld.[dvec & 1]) == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)
249 break;
250
251 rbt_hpush4cxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:97:9`!(h, rbt_node_ptr(h[0])->_chld[dvec & 1]);
252 n_key = rbt_str_nodecxx . . $ rbt_str_node(c08d81df1cfaabdf).(h[0])->keycxx . . $ rbt_str_node#key.;
253 cmp = strcmpcxx . . $ strcmp(5ae29d726ae57f88).(u_key, n_key);
254
255 if (cmp < 0) {
256 dvec = (dvec << 1) | RBT_NODE_SLcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:71:9`!;
257 } else if (cmp > 0) {
258 dvec = (dvec << 1) | RBT_NODE_SRcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:72:9`!;
259 } else {
260 save = rbt_node_ptrcxx . . $ rbt_node_ptr(a7124440667b6d30).(h[0]);
261 dvec = (dvec << 1) | RBT_NODE_SLcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:71:9`!;
262 }
263
264 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`! &&
265 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`!)
266 {
267 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`!) {
268 switch(dvec & 1) {
269 case RBT_NODE_SRcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:72:9`!:
270 rbt_node_setptrcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:81:9`!(rbt_node_ptr(h[1])->_chld[(dvec >> 1) & 1],
271 rbt_node_rotate_R(h[0]));
272 break;
273 case RBT_NODE_SLcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:71:9`!:
274 rbt_node_setptrcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:81:9`!(rbt_node_ptr(h[1])->_chld[(dvec >> 1) & 1],
275 rbt_node_rotate_L(h[0]));
276 break;
277 }
278
279 h[1] = rbt_node_ptrcxx . . $ rbt_node_ptr(a7124440667b6d30).(h[1])->_chldcxx . . $ rbt_node#_chld.[(dvec >> 1) & 1];
280 } else {
281 register struct rbt_nodecxx . . $ rbt_node# *s;
282
283 s = rbt_node_ptrcxx . . $ rbt_node_ptr(a7124440667b6d30).(rbt_node_ptrcxx . . $ rbt_node_ptr(a7124440667b6d30).(h[1])->_chldcxx . . $ rbt_node#_chld.[!((dvec >> 1) & 1)]);
284
285 if (s != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
286 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`! &&
287 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`!)
288 {
289 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`!);
290 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`!);
291 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`!);
292 } else {
293 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]);
294
295 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`!) {
296 switch((dvec >> 1) & 1) {
297 case RBT_NODE_SRcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:72:9`!:
298 rbt_node_setptrcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:81:9`!(rbt_node_ptr(h[2])->_chld[d],
299 rbt_node_rotate_RL(h[1]));
300 break;
301 case RBT_NODE_SLcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:71:9`!:
302 rbt_node_setptrcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:81:9`!(rbt_node_ptr(h[2])->_chld[d],
303 rbt_node_rotate_LR(h[1]));
304 break;
305 }
306 } 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`!) {
307 switch((dvec >> 1) & 1) {
308 case RBT_NODE_SRcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:72:9`!:
309 rbt_node_setptrcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:81:9`!(rbt_node_ptr(h[2])->_chld[d],
310 rbt_node_rotate_R(h[1]));
311 break;
312 case RBT_NODE_SLcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:71:9`!:
313 rbt_node_setptrcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:81:9`!(rbt_node_ptr(h[2])->_chld[d],
314 rbt_node_rotate_L(h[1]));
315 break;
316 }
317 }
318
319 s = rbt_node_ptrcxx . . $ rbt_node_ptr(a7124440667b6d30).(rbt_node_ptrcxx . . $ rbt_node_ptr(a7124440667b6d30).(h[2])->_chldcxx . . $ rbt_node#_chld.[d]);
320
321 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`!);
322 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`!);
323 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`!);
324 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`!);
325 }
326 }
327 }
328 }
329 }
330
331 if (save != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
332 h[0] = rbt_node_ptrcxx . . $ rbt_node_ptr(a7124440667b6d30).(h[0]);
333 /*
334 * The node color of the node that will be delete is always
335 * red in case the node is not the root node.
336 */
337 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]
338 && 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`!) {
339 return -1;
340 }
341 if (n != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)
342 *n = rbt_str_nodecxx . . $ rbt_str_node(c08d81df1cfaabdf).(save)->datacxx . . $ rbt_str_node#data.;
343
344 rbt_str_nodecxx . . $ rbt_str_node(c08d81df1cfaabdf).(save)->datacxx . . $ rbt_str_node#data. = rbt_str_nodecxx . . $ rbt_str_node(c08d81df1cfaabdf).(h[0])->datacxx . . $ rbt_str_node#data.;
345 rbt_str_nodecxx . . $ rbt_str_node(c08d81df1cfaabdf).(save)->keycxx . . $ rbt_str_node#key. = rbt_str_nodecxx . . $ rbt_str_node(c08d81df1cfaabdf).(h[0])->keycxx . . $ rbt_str_node#key.;
346
347 dvec = rbt_node_ptrcxx . . $ rbt_node_ptr(a7124440667b6d30).(rbt_node_ptrcxx . . $ rbt_node_ptr(a7124440667b6d30).(h[1])->_chldcxx . . $ rbt_node#_chld.[1]) == h[0];
348
349 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 . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
350 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`!]);
351 } else {
352 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`!]);
353 }
354
355 /*
356 * Free memory used by the deleted node and decrement
357 * the node counter.
358 */
359 rbt_str_node_freecxx . . $ rbt_str_node_free(ea57ab5850a9e42).(h[0]);
360 --(rbt->sizecxx . . $ rbt#size.);
361 }
362
363 /*
364 * Update root node and color it black and unlock the tree.
365 */
366 rbt->rootcxx . . $ rbt#root. = fake._chldcxx . . $ rbt_node#_chld.[RBT_NODE_SRcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:72:9`!];
367 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`!);
368 rbt_wunlockcxx . . $ rbt_wunlock(c2e6369c3901716e).(rbt);
369
370 return (save == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`! ? 1 : 0);
371 }
372
373 int rbt_str_getnodecxx . . $ rbt_str_getnode(6894629c5d675ab5).(rbt_tcxx . . $ rbt_t# *rbt, const char *key, struct rbt_str_nodecxx . . $ rbt_str_node# **node)
374 {
375 int r;
376 register struct rbt_nodecxx . . $ rbt_node# *n;
377 register char *u_key, *n_key;
378 register int cmp;
379
380 u_key = (char *)key;
381 r = -1;
382 rbt_rlockcxx . . $ rbt_rlock(5b7afdec655f93de).(rbt);
383 n = rbt_node_ptrcxx . . $ rbt_node_ptr(a7124440667b6d30).(rbt->rootcxx . . $ rbt#root.);
384
385 while (n != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
386 n_key = rbt_str_nodecxx . . $ rbt_str_node(c08d81df1cfaabdf).(n)->keycxx . . $ rbt_str_node#key.;
387 cmp = strcmpcxx . . $ strcmp(5ae29d726ae57f88).(u_key, n_key);
388
389 if (cmp < 0)
390 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`!]);
391 else if (cmp > 0)
392 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`!]);
393 else {
394 r = 0;
395 *node = (struct rbt_str_nodecxx . . $ rbt_str_node# *)(n->_nodecxx . . $ rbt_node#_node.);
396 break;
397 }
398 }
399
400 rbt_runlockcxx . . $ rbt_runlock(c2e6369c3901716e).(rbt);
401 return (r);
402 }
403
404 int rbt_str_getcxx . . $ rbt_str_get(3cd4f904f7b02e6c).(rbt_tcxx . . $ rbt_t# *rbt, const char *key, void **data)
405 {
406 int r;
407 struct rbt_str_nodecxx . . $ rbt_str_node# *n = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
408
409 r = rbt_str_getnodecxx . . $ rbt_str_getnode(6894629c5d675ab5).(rbt, key, &n);
410
411 if (r == 0)
412 *data = n->datacxx . . $ rbt_str_node#data.;
413
414 return(r);
415 }
416
417 int rbt_str_walk_preordercxx . . $ rbt_str_walk_preorder(f14df7593322124e).(rbt_tcxx . . $ rbt_t# *rbt, int (*callback)(struct rbt_str_nodecxx . . $ rbt_str_node# *), rbt_walk_tcxx . . $ rbt_walk_t# flags)
418 {
419 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = ENOSYScxx . . $ `<external>/17922322188510340118/errno.h:18:9`!;
420 return (-1);
421 }
422
423 int rbt_str_walk_inordercxx . . $ rbt_str_walk_inorder(f14df7593322124e).(rbt_tcxx . . $ rbt_t# *rbt, int (*callback)(struct rbt_str_nodecxx . . $ rbt_str_node# *), rbt_walk_tcxx . . $ rbt_walk_t# flags)
424 {
425 return rbt_walk_inordercxx . . $ rbt_walk_inorder(c23f1c7969ddfc49).(rbt, (int(*)(void *))callback, flags);
426 }
427
428 int rbt_str_walk_inorder2cxx . . $ rbt_str_walk_inorder2(1f9f5f59823fc556).(rbt_tcxx . . $ rbt_t# *rbt, int (*callback)(struct rbt_str_nodecxx . . $ rbt_str_node# *, void *), void *user, rbt_walk_tcxx . . $ rbt_walk_t# flags)
429 {
430 return rbt_walk_inorder2cxx . . $ rbt_walk_inorder2(bba4ddba429b8b1).(rbt, (int(*)(void *, void *))callback, user, flags);
431 }
432
433 int rbt_str_walk_postordercxx . . $ rbt_str_walk_postorder(f14df7593322124e).(rbt_tcxx . . $ rbt_t# *rbt, int (*callback)(struct rbt_str_nodecxx . . $ rbt_str_node# *), rbt_walk_tcxx . . $ rbt_walk_t# flags)
434 {
435 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = ENOSYScxx . . $ `<external>/17922322188510340118/errno.h:18:9`!;
436 return (-1);
437 }
438
439 int rbt_str_walk_levelordercxx . . $ rbt_str_walk_levelorder(f14df7593322124e).(rbt_tcxx . . $ rbt_t# *rbt, int (*callback)(struct rbt_str_nodecxx . . $ rbt_str_node# *), rbt_walk_tcxx . . $ rbt_walk_t# flags)
440 {
441 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = ENOSYScxx . . $ `<external>/17922322188510340118/errno.h:18:9`!;
442 return (-1);
443 }
444
445 int rbt_str_walkcxx . . $ rbt_str_walk(f5bf59eee56ddbd).(rbt_tcxx . . $ rbt_t# *rbt, rbt_walk_tcxx . . $ rbt_walk_t# type, int (*callback)(struct rbt_str_nodecxx . . $ rbt_str_node# *))
446 {
447 if (rbt == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`! || callback == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
448 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = EINVALcxx . . $ `<external>/8987895939074593727/errno-base.h:26:9`!;
449 return -1;
450 }
451
452 switch (type & RBT_WALK_TYPEMASKcxx . . $ `src/OVAL/probes/SEAP/generic/rbt/rbt_common.h:57:9`!) {
453 case RBT_WALK_PREORDERcxx . . $ RBT_WALK_PREORDER.: return rbt_str_walk_preordercxx . . $ rbt_str_walk_preorder(f14df7593322124e).(rbt, callback, type);
454 case RBT_WALK_INORDERcxx . . $ RBT_WALK_INORDER.: return rbt_str_walk_inordercxx . . $ rbt_str_walk_inorder(f14df7593322124e).(rbt, callback, type);
455 case RBT_WALK_POSTORDERcxx . . $ RBT_WALK_POSTORDER.: return rbt_str_walk_postordercxx . . $ rbt_str_walk_postorder(f14df7593322124e).(rbt, callback, type);
456 case RBT_WALK_LEVELORDERcxx . . $ RBT_WALK_LEVELORDER.: return rbt_str_walk_levelordercxx . . $ rbt_str_walk_levelorder(f14df7593322124e).(rbt, callback, type);
457 }
458
459 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = EINVALcxx . . $ `<external>/8987895939074593727/errno-base.h:26:9`!;
460 return (-1);
461 }
462
463 size_t rbt_str_sizecxx . . $ rbt_str_size(6ae908cc234686bf).(rbt_tcxx . . $ rbt_t# *rbt)
464 {
465 return rbt_sizecxx . . $ rbt_size(6ae908cc234686bf).(rbt);
466 }