Compare commits

...

2 Commits

Author SHA1 Message Date
Yat Ho b49604a238 code review: explain 15KB in Win32 interface index code 2024-04-28 10:43:03 +08:00
Yat Ho 53e4c80459 fixup! code review: unify comment styles 2024-04-28 10:29:03 +08:00
2 changed files with 8 additions and 1 deletions

View File

@ -572,6 +572,13 @@ std::optional<unsigned> tr_address::to_interface_index() const noexcept
#ifdef _WIN32
auto p_addresses = std::unique_ptr<void, void (*)(void*)>{ nullptr, operator delete };
// The recommended method of calling the GetAdaptersAddresses function is to
// pre-allocate a 15KB working buffer pointed to by the AdapterAddresses parameter.
// On typical computers, this dramatically reduces the chances that the
// GetAdaptersAddresses function returns ERROR_BUFFER_OVERFLOW, which would require
// calling GetAdaptersAddresses function multiple times.
// https://learn.microsoft.com/en-us/windows/win32/api/iphlpapi/nf-iphlpapi-getadaptersaddresses
for (auto p_addresses_size = ULONG{ 15000 } /* 15KB */;;)
{
p_addresses.reset(operator new(p_addresses_size, std::nothrow));

View File

@ -655,7 +655,7 @@ private:
std::string const cookie_ = makeCookie();
Mediator& mediator_;
std::array<tr_socket_t, NUM_TR_AF_INET_TYPES> mcast_sockets_ = { TR_BAD_SOCKET, TR_BAD_SOCKET }; /**multicast sockets */
std::array<tr_socket_t, NUM_TR_AF_INET_TYPES> mcast_sockets_ = { TR_BAD_SOCKET, TR_BAD_SOCKET }; // multicast sockets
std::array<libtransmission::evhelpers::event_unique_ptr, NUM_TR_AF_INET_TYPES> events_;
static auto constexpr MaxDatagramLength = size_t{ 1400 };