diff options
| author | Lioncash <mai.iam2048@gmail.com> | 2023-04-19 12:25:21 -0400 |
|---|---|---|
| committer | Lioncash <mai.iam2048@gmail.com> | 2023-04-19 12:38:16 -0400 |
| commit | b4cc1ade020665d0ba8f5c5e40c7f4f1ce90ec38 (patch) | |
| tree | 6fcd921532ad3b16a4af432d7d82470838f88f2a /Source/Core/Common/TraversalClient.cpp | |
| parent | 6d8cabac49b29578f729d765357ad84674547b40 (diff) | |
Common/TraversalClient: Use correct deleter with g_MainNetHost
Previously this was using the default deleter (which just calls delete
on the pointer), which is incorrect, since the ENetHost instance is
allocated through ENet's C API, so we need to use its functions to
deallocate the host instead.
Diffstat (limited to 'Source/Core/Common/TraversalClient.cpp')
| -rw-r--r-- | Source/Core/Common/TraversalClient.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/Source/Core/Common/TraversalClient.cpp b/Source/Core/Common/TraversalClient.cpp index f3ab481a51..b215e5d269 100644 --- a/Source/Core/Common/TraversalClient.cpp +++ b/Source/Core/Common/TraversalClient.cpp @@ -304,7 +304,7 @@ int ENET_CALLBACK TraversalClient::InterceptCallback(ENetHost* host, ENetEvent* } std::unique_ptr<TraversalClient> g_TraversalClient; -std::unique_ptr<ENetHost> g_MainNetHost; +Common::ENet::ENetHostPtr g_MainNetHost; // The settings at the previous TraversalClient reset - notably, we // need to know not just what port it's on, but whether it was @@ -323,18 +323,18 @@ bool EnsureTraversalClient(const std::string& server, u16 server_port, u16 liste g_OldListenPort = listen_port; ENetAddress addr = {ENET_HOST_ANY, listen_port}; - ENetHost* host = enet_host_create(&addr, // address - 50, // peerCount - NetPlay::CHANNEL_COUNT, // channelLimit - 0, // incomingBandwidth - 0); // outgoingBandwidth + auto host = Common::ENet::ENetHostPtr{enet_host_create(&addr, // address + 50, // peerCount + NetPlay::CHANNEL_COUNT, // channelLimit + 0, // incomingBandwidth + 0)}; // outgoingBandwidth if (!host) { g_MainNetHost.reset(); return false; } host->mtu = std::min(host->mtu, NetPlay::MAX_ENET_MTU); - g_MainNetHost.reset(host); + g_MainNetHost = std::move(host); g_TraversalClient.reset(new TraversalClient(g_MainNetHost.get(), server, server_port)); } return true; |
