[srp-client] use LinkedList::RemoveAllMatching() (#7221)

This commit is contained in:
Abtin Keshavarzian
2021-12-07 14:43:01 -08:00
committed by Jonathan Hui
parent 8650e15a37
commit 3c01127770
2 changed files with 2 additions and 21 deletions
+1 -21
View File
@@ -1355,27 +1355,7 @@ void Client::HandleUpdateDone(void)
void Client::GetRemovedServices(LinkedList<Service> &aRemovedServices)
{
Service *service;
Service *prev;
Service *next;
for (prev = nullptr, service = mServices.GetHead(); service != nullptr; service = next)
{
next = service->GetNext();
if (service->GetState() == kRemoved)
{
mServices.PopAfter(prev);
aRemovedServices.Push(*service);
// When the service is removed from the list
// we keep the `prev` pointer same as before.
}
else
{
prev = service;
}
}
mServices.RemoveAllMatching(kRemoved, aRemovedServices);
}
Error Client::ReadResourceRecord(const Message &aMessage, uint16_t &aOffset, Dns::ResourceRecord &aRecord)
+1
View File
@@ -267,6 +267,7 @@ public:
TimeMilli GetLeaseRenewTime(void) const { return TimeMilli(mData); }
void SetLeaseRenewTime(TimeMilli aTime) { mData = aTime.GetValue(); }
bool Matches(const Service &aOther) const;
bool Matches(ItemState aState) const { return GetState() == aState; }
};
/**