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.
This commit is contained in:
Lioncash
2023-04-19 12:25:21 -04:00
parent 6d8cabac49
commit b4cc1ade02
3 changed files with 17 additions and 9 deletions

View File

@ -11,6 +11,7 @@
#include <enet/enet.h>
#include "Common/CommonTypes.h"
#include "Common/ENet.h"
#include "Common/Thread.h"
#include "Common/TraversalProto.h"
@ -91,7 +92,7 @@ private:
};
extern std::unique_ptr<TraversalClient> g_TraversalClient;
// the NetHost connected to the TraversalClient.
extern std::unique_ptr<ENetHost> g_MainNetHost;
extern Common::ENet::ENetHostPtr g_MainNetHost;
// Create g_TraversalClient and g_MainNetHost if necessary.
bool EnsureTraversalClient(const std::string& server, u16 server_port, u16 listen_port = 0);
void ReleaseTraversalClient();