diff --git a/src/core/net/srp_client.cpp b/src/core/net/srp_client.cpp index d8d196098..a9022b462 100644 --- a/src/core/net/srp_client.cpp +++ b/src/core/net/srp_client.cpp @@ -1355,27 +1355,7 @@ void Client::HandleUpdateDone(void) void Client::GetRemovedServices(LinkedList &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) diff --git a/src/core/net/srp_client.hpp b/src/core/net/srp_client.hpp index 3e0794d73..923abe658 100644 --- a/src/core/net/srp_client.hpp +++ b/src/core/net/srp_client.hpp @@ -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; } }; /**