diff options
Diffstat (limited to 'src/util/test_container_dll.c')
-rw-r--r-- | src/util/test_container_dll.c | 79 |
1 files changed, 39 insertions, 40 deletions
diff --git a/src/util/test_container_dll.c b/src/util/test_container_dll.c index f1c0e9446..7203cde22 100644 --- a/src/util/test_container_dll.c +++ b/src/util/test_container_dll.c | |||
@@ -1,19 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2017 GNUnet e.V. | 3 | Copyright (C) 2017 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation, either version 3 of the License, | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | or (at your option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
@@ -30,8 +30,7 @@ | |||
30 | /** | 30 | /** |
31 | * Element in the DLL. | 31 | * Element in the DLL. |
32 | */ | 32 | */ |
33 | struct Element | 33 | struct Element { |
34 | { | ||
35 | /** | 34 | /** |
36 | * Required pointer to previous element. | 35 | * Required pointer to previous element. |
37 | */ | 36 | */ |
@@ -58,9 +57,9 @@ struct Element | |||
58 | * @return #GNUNET_YES if @e1 < @e2, otherwise #GNUNET_NO | 57 | * @return #GNUNET_YES if @e1 < @e2, otherwise #GNUNET_NO |
59 | */ | 58 | */ |
60 | static int | 59 | static int |
61 | cmp_elem (void *cls, | 60 | cmp_elem(void *cls, |
62 | struct Element *e1, | 61 | struct Element *e1, |
63 | struct Element *e2) | 62 | struct Element *e2) |
64 | { | 63 | { |
65 | if (e1->value == e2->value) | 64 | if (e1->value == e2->value) |
66 | return 0; | 65 | return 0; |
@@ -69,7 +68,7 @@ cmp_elem (void *cls, | |||
69 | 68 | ||
70 | 69 | ||
71 | int | 70 | int |
72 | main (int argc, char **argv) | 71 | main(int argc, char **argv) |
73 | { | 72 | { |
74 | unsigned int values[] = { | 73 | unsigned int values[] = { |
75 | 4, 5, 8, 6, 9, 3, 7, 2, 1, 0 | 74 | 4, 5, 8, 6, 9, 3, 7, 2, 1, 0 |
@@ -79,33 +78,33 @@ main (int argc, char **argv) | |||
79 | struct Element *e; | 78 | struct Element *e; |
80 | unsigned int want; | 79 | unsigned int want; |
81 | 80 | ||
82 | GNUNET_log_setup ("test-container-dll", | 81 | GNUNET_log_setup("test-container-dll", |
83 | "WARNING", | 82 | "WARNING", |
84 | NULL); | 83 | NULL); |
85 | for (unsigned int off=0; | 84 | for (unsigned int off = 0; |
86 | 0 != values[off]; | 85 | 0 != values[off]; |
87 | off++) | 86 | off++) |
88 | { | 87 | { |
89 | e = GNUNET_new (struct Element); | 88 | e = GNUNET_new(struct Element); |
90 | e->value = values[off]; | 89 | e->value = values[off]; |
91 | GNUNET_CONTAINER_DLL_insert_sorted (struct Element, | 90 | GNUNET_CONTAINER_DLL_insert_sorted(struct Element, |
92 | cmp_elem, | 91 | cmp_elem, |
93 | NULL, | 92 | NULL, |
94 | head, | 93 | head, |
95 | tail, | 94 | tail, |
96 | e); | 95 | e); |
97 | } | 96 | } |
98 | 97 | ||
99 | want = 1; | 98 | want = 1; |
100 | while (NULL != (e = head)) | 99 | while (NULL != (e = head)) |
101 | { | 100 | { |
102 | GNUNET_assert (e->value == want); | 101 | GNUNET_assert(e->value == want); |
103 | GNUNET_CONTAINER_DLL_remove (head, | 102 | GNUNET_CONTAINER_DLL_remove(head, |
104 | tail, | 103 | tail, |
105 | e); | 104 | e); |
106 | GNUNET_free (e); | 105 | GNUNET_free(e); |
107 | want++; | 106 | want++; |
108 | } | 107 | } |
109 | return 0; | 108 | return 0; |
110 | } | 109 | } |
111 | 110 | ||