24
24
namespace chip {
25
25
namespace app {
26
26
27
+ namespace {
28
+
29
+ // / Remove all elements of a linked list rom the linked list.
30
+ // /
31
+ // / Marks every element in the given linked list as not being in a
32
+ // / linked list anymore.
33
+ void ClearSingleLinkedList (ServerClusterInterface * clusters)
34
+ {
35
+ while (clusters != nullptr )
36
+ {
37
+ ServerClusterInterface * next = clusters->GetNextListItem ();
38
+ clusters->SetNotInList ();
39
+ clusters = next;
40
+ }
41
+ }
42
+
43
+ } // namespace
44
+
27
45
ServerClusterInterfaceRegistry & ServerClusterInterfaceRegistry::Instance ()
28
46
{
29
47
static ServerClusterInterfaceRegistry sRegistry ;
@@ -137,16 +155,6 @@ ServerClusterInterface * ServerClusterInterfaceRegistry::Unregister(const Concre
137
155
return nullptr ;
138
156
}
139
157
140
- void ServerClusterInterfaceRegistry::DestroySingleLinkedList (ServerClusterInterface * clusters)
141
- {
142
- while (clusters != nullptr )
143
- {
144
- ServerClusterInterface * next = clusters->GetNextListItem ();
145
- clusters->SetNotInList ();
146
- clusters = next;
147
- }
148
- }
149
-
150
158
void ServerClusterInterfaceRegistry::UnregisterAllFromEndpoint (EndpointId endpointId)
151
159
{
152
160
if ((mEndpointClustersCache != nullptr ) && (mEndpointClustersCache ->endpointId == endpointId))
@@ -167,7 +175,7 @@ void ServerClusterInterfaceRegistry::UnregisterAllFromEndpoint(EndpointId endpoi
167
175
if (ep.endpointId == endpointId)
168
176
{
169
177
ep.endpointId = kInvalidEndpointId ;
170
- DestroySingleLinkedList (ep.firstCluster );
178
+ ClearSingleLinkedList (ep.firstCluster );
171
179
ep.firstCluster = nullptr ;
172
180
return ;
173
181
}
@@ -179,7 +187,7 @@ void ServerClusterInterfaceRegistry::UnregisterAllFromEndpoint(EndpointId endpoi
179
187
{
180
188
DynamicEndpointClusters * value = mDynamicEndpoints ;
181
189
mDynamicEndpoints = mDynamicEndpoints ->next ;
182
- DestroySingleLinkedList (value->firstCluster );
190
+ ClearSingleLinkedList (value->firstCluster );
183
191
Platform::Delete (value);
184
192
return ;
185
193
}
@@ -191,7 +199,7 @@ void ServerClusterInterfaceRegistry::UnregisterAllFromEndpoint(EndpointId endpoi
191
199
if (current->endpointId == endpointId)
192
200
{
193
201
prev->next = current->next ;
194
- DestroySingleLinkedList (current->firstCluster );
202
+ ClearSingleLinkedList (current->firstCluster );
195
203
Platform::Delete (current);
196
204
return ;
197
205
}
0 commit comments