diff options
Diffstat (limited to 'src/messenger/gnunet-service-messenger_list_handles.c')
-rw-r--r-- | src/messenger/gnunet-service-messenger_list_handles.c | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/src/messenger/gnunet-service-messenger_list_handles.c b/src/messenger/gnunet-service-messenger_list_handles.c index 0703c2de6..826e1f4ed 100644 --- a/src/messenger/gnunet-service-messenger_list_handles.c +++ b/src/messenger/gnunet-service-messenger_list_handles.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2020--2022 GNUnet e.V. | 3 | Copyright (C) 2020--2023 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 |
@@ -31,48 +31,52 @@ | |||
31 | void | 31 | void |
32 | init_list_handles (struct GNUNET_MESSENGER_ListHandles *handles) | 32 | init_list_handles (struct GNUNET_MESSENGER_ListHandles *handles) |
33 | { | 33 | { |
34 | GNUNET_assert(handles); | 34 | GNUNET_assert (handles); |
35 | 35 | ||
36 | handles->head = NULL; | 36 | handles->head = NULL; |
37 | handles->tail = NULL; | 37 | handles->tail = NULL; |
38 | } | 38 | } |
39 | 39 | ||
40 | |||
40 | void | 41 | void |
41 | clear_list_handles (struct GNUNET_MESSENGER_ListHandles *handles) | 42 | clear_list_handles (struct GNUNET_MESSENGER_ListHandles *handles) |
42 | { | 43 | { |
43 | GNUNET_assert(handles); | 44 | GNUNET_assert (handles); |
44 | 45 | ||
45 | while (handles->head) | 46 | while (handles->head) |
46 | { | 47 | { |
47 | struct GNUNET_MESSENGER_ListHandle *element = handles->head; | 48 | struct GNUNET_MESSENGER_ListHandle *element = handles->head; |
48 | 49 | ||
49 | GNUNET_CONTAINER_DLL_remove(handles->head, handles->tail, element); | 50 | GNUNET_CONTAINER_DLL_remove (handles->head, handles->tail, element); |
50 | destroy_srv_handle (element->handle); | 51 | destroy_srv_handle (element->handle); |
51 | GNUNET_free(element); | 52 | GNUNET_free (element); |
52 | } | 53 | } |
53 | 54 | ||
54 | handles->head = NULL; | 55 | handles->head = NULL; |
55 | handles->tail = NULL; | 56 | handles->tail = NULL; |
56 | } | 57 | } |
57 | 58 | ||
59 | |||
58 | void | 60 | void |
59 | add_list_handle (struct GNUNET_MESSENGER_ListHandles *handles, | 61 | add_list_handle (struct GNUNET_MESSENGER_ListHandles *handles, |
60 | struct GNUNET_MESSENGER_SrvHandle *handle) | 62 | struct GNUNET_MESSENGER_SrvHandle *handle) |
61 | { | 63 | { |
62 | GNUNET_assert((handles) && (handle)); | 64 | GNUNET_assert ((handles) && (handle)); |
63 | 65 | ||
64 | struct GNUNET_MESSENGER_ListHandle *element = GNUNET_new(struct GNUNET_MESSENGER_ListHandle); | 66 | struct GNUNET_MESSENGER_ListHandle *element = GNUNET_new (struct |
67 | GNUNET_MESSENGER_ListHandle); | ||
65 | 68 | ||
66 | element->handle = handle; | 69 | element->handle = handle; |
67 | 70 | ||
68 | GNUNET_CONTAINER_DLL_insert_tail(handles->head, handles->tail, element); | 71 | GNUNET_CONTAINER_DLL_insert_tail (handles->head, handles->tail, element); |
69 | } | 72 | } |
70 | 73 | ||
74 | |||
71 | int | 75 | int |
72 | remove_list_handle (struct GNUNET_MESSENGER_ListHandles *handles, | 76 | remove_list_handle (struct GNUNET_MESSENGER_ListHandles *handles, |
73 | struct GNUNET_MESSENGER_SrvHandle *handle) | 77 | struct GNUNET_MESSENGER_SrvHandle *handle) |
74 | { | 78 | { |
75 | GNUNET_assert((handles) && (handle)); | 79 | GNUNET_assert ((handles) && (handle)); |
76 | 80 | ||
77 | struct GNUNET_MESSENGER_ListHandle *element; | 81 | struct GNUNET_MESSENGER_ListHandle *element; |
78 | 82 | ||
@@ -80,25 +84,28 @@ remove_list_handle (struct GNUNET_MESSENGER_ListHandles *handles, | |||
80 | if (element->handle == handle) | 84 | if (element->handle == handle) |
81 | break; | 85 | break; |
82 | 86 | ||
83 | if (!element) | 87 | if (! element) |
84 | return GNUNET_NO; | 88 | return GNUNET_NO; |
85 | 89 | ||
86 | GNUNET_CONTAINER_DLL_remove(handles->head, handles->tail, element); | 90 | GNUNET_CONTAINER_DLL_remove (handles->head, handles->tail, element); |
87 | GNUNET_free(element); | 91 | GNUNET_free (element); |
88 | 92 | ||
89 | return GNUNET_YES; | 93 | return GNUNET_YES; |
90 | } | 94 | } |
91 | 95 | ||
96 | |||
92 | struct GNUNET_MESSENGER_SrvHandle* | 97 | struct GNUNET_MESSENGER_SrvHandle* |
93 | find_list_handle_by_member (const struct GNUNET_MESSENGER_ListHandles *handles, | 98 | find_list_handle_by_member (const struct GNUNET_MESSENGER_ListHandles *handles, |
94 | const struct GNUNET_HashCode *key) | 99 | const struct GNUNET_HashCode *key) |
95 | { | 100 | { |
96 | GNUNET_assert((handles) && (key)); | 101 | GNUNET_assert ((handles) && (key)); |
97 | 102 | ||
98 | struct GNUNET_MESSENGER_ListHandle *element; | 103 | struct GNUNET_MESSENGER_ListHandle *element; |
99 | 104 | ||
100 | for (element = handles->head; element; element = element->next) | 105 | for (element = handles->head; element; element = element->next) |
101 | if (get_srv_handle_member_id ((struct GNUNET_MESSENGER_SrvHandle*) element->handle, key)) | 106 | if (get_srv_handle_member_id ((struct |
107 | GNUNET_MESSENGER_SrvHandle*) element->handle, | ||
108 | key)) | ||
102 | return element->handle; | 109 | return element->handle; |
103 | 110 | ||
104 | return NULL; | 111 | return NULL; |