mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-23 02:31:55 +00:00
Kernel: Use WeakPtr<NetworkAdapter> instead of NetworkAdapter* in net code
This commit is contained in:
parent
d6bce37756
commit
54ceabd48d
Notes:
sideshowbarker
2024-07-19 12:48:48 +09:00
Author: https://github.com/deoxxa
Commit: 54ceabd48d
Pull-request: https://github.com/SerenityOS/serenity/pull/421
Reviewed-by: https://github.com/awesomekling ✅
9 changed files with 28 additions and 16 deletions
|
@ -22,12 +22,12 @@ void NetworkAdapter::for_each(Function<void(NetworkAdapter&)> callback)
|
|||
callback(*it);
|
||||
}
|
||||
|
||||
NetworkAdapter* NetworkAdapter::from_ipv4_address(const IPv4Address& address)
|
||||
WeakPtr<NetworkAdapter> NetworkAdapter::from_ipv4_address(const IPv4Address& address)
|
||||
{
|
||||
LOCKER(all_adapters().lock());
|
||||
for (auto* adapter : all_adapters().resource()) {
|
||||
if (adapter->ipv4_address() == address)
|
||||
return adapter;
|
||||
return adapter->make_weak_ptr();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue