Debian Codegraph @

src/common/oscap_queue.c

raw symbols SCIP
1 /*
2 * Copyright 2018 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 * Jan Černý <[email protected]>
21 */
22
23
24 #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:409:9`!
25 #include <config.h>cxx . . $ `<file>/build/config.h`/
26 #endif
27
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include "util.h"cxx . . $ `<file>/src/common/util.h`/
31 #include "oscap_queue.h"cxx . . $ `<file>/src/common/oscap_queue.h`/
32
33 struct oscap_queue_itemcxx . . $ oscap_queue_item# {
34 void *datacxx . . $ oscap_queue_item#data.;
35 struct oscap_queue_itemcxx . . $ oscap_queue_item# *nextcxx . . $ oscap_queue_item#next.;
36 };
37
38 struct oscap_queuecxx . . $ oscap_queue# {
39 struct oscap_queue_itemcxx . . $ oscap_queue_item# *begincxx . . $ oscap_queue#begin.;
40 struct oscap_queue_itemcxx . . $ oscap_queue_item# *endcxx . . $ oscap_queue#end.;
41 };
42
43 struct oscap_queuecxx . . $ oscap_queue# *oscap_queue_newcxx . . $ oscap_queue_new(bdf6ccca4559a142).()
44 {
45 struct oscap_queuecxx . . $ oscap_queue# *queue = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(struct oscap_queuecxx . . $ oscap_queue#));
46 queue->begincxx . . $ oscap_queue#begin. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
47 queue->endcxx . . $ oscap_queue#end. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
48 return queue;
49 }
50
51 void oscap_queue_addcxx . . $ oscap_queue_add(71ccb11e7c91f23b).(struct oscap_queuecxx . . $ oscap_queue# *queue, void *data)
52 {
53 struct oscap_queue_itemcxx . . $ oscap_queue_item# *temp = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(struct oscap_queue_itemcxx . . $ oscap_queue_item#));
54 temp->datacxx . . $ oscap_queue_item#data. = data;
55 temp->nextcxx . . $ oscap_queue_item#next. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
56 if (queue->begincxx . . $ oscap_queue#begin. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
57 queue->begincxx . . $ oscap_queue#begin. = temp;
58 } else {
59 queue->endcxx . . $ oscap_queue#end.->nextcxx . . $ oscap_queue_item#next. = temp;
60 }
61 queue->endcxx . . $ oscap_queue#end. = temp;
62 }
63
64 void *oscap_queue_removecxx . . $ oscap_queue_remove(1607303aa7bc3f96).(struct oscap_queuecxx . . $ oscap_queue# *queue)
65 {
66 if (queue->begincxx . . $ oscap_queue#begin. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
67 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
68 }
69 void *data = queue->begincxx . . $ oscap_queue#begin.->datacxx . . $ oscap_queue_item#data.;
70 struct oscap_queue_itemcxx . . $ oscap_queue_item# *temp = queue->begincxx . . $ oscap_queue#begin.;
71 if (queue->begincxx . . $ oscap_queue#begin. == queue->endcxx . . $ oscap_queue#end.) {
72 queue->endcxx . . $ oscap_queue#end. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
73 }
74 queue->begincxx . . $ oscap_queue#begin. = queue->begincxx . . $ oscap_queue#begin.->nextcxx . . $ oscap_queue_item#next.;
75 freecxx . . $ free(5d22bdacc48458e8).(temp);
76 return data;
77 }
78
79 void oscap_queue_freecxx . . $ oscap_queue_free(879664d74130d69b).(struct oscap_queuecxx . . $ oscap_queue# *queue, oscap_destruct_funccxx . . $ oscap_destruct_func# destructor)
80 {
81 if (queue == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
82 return;
83 }
84 struct oscap_queue_itemcxx . . $ oscap_queue_item# *current, *temp;
85 current = queue->begincxx . . $ oscap_queue#begin.;
86 while (current != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
87 temp = current;
88 current = current->nextcxx . . $ oscap_queue_item#next.;
89 if (destructor != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
90 freecxx . . $ free(5d22bdacc48458e8).(temp->datacxx . . $ oscap_queue_item#data.);
91 }
92 freecxx . . $ free(5d22bdacc48458e8).(temp);
93 }
94 freecxx . . $ free(5d22bdacc48458e8).(queue);
95 }