1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-21 23:32:35 +00:00

refactor: simplify addrinfo unique_ptr definition (#7060)

This commit is contained in:
Yat Ho 2024-08-13 18:12:02 +08:00 committed by GitHub
parent dbea32809a
commit 7e2212bfe0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -512,10 +512,7 @@ private:
fmt::arg("error_code", static_cast<int>(rc))));
return {};
}
auto const info_uniq = std::unique_ptr<addrinfo, void (*)(addrinfo*)>{
info,
[](addrinfo* p) { freeaddrinfo(p); }, // MSVC forced me to write this lambda wrapper
};
auto const info_uniq = std::unique_ptr<addrinfo, decltype(&freeaddrinfo)>{ info, freeaddrinfo };
// N.B. getaddrinfo() will return IPv4-mapped addresses by default on macOS
auto socket_address = tr_socket_address::from_sockaddr(info->ai_addr);