dolphin/Source/Core/Common/ENet.h
Lioncash b4cc1ade02 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.
2023-04-19 12:38:16 -04:00

24 lines
623 B
C++

// Copyright 2015 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
//
#pragma once
#include <memory>
#include <SFML/Network/Packet.hpp>
#include <enet/enet.h>
#include "Common/CommonTypes.h"
namespace Common::ENet
{
struct ENetHostDeleter
{
void operator()(ENetHost* host) const noexcept { enet_host_destroy(host); }
};
using ENetHostPtr = std::unique_ptr<ENetHost, ENetHostDeleter>;
void WakeupThread(ENetHost* host);
int ENET_CALLBACK InterceptCallback(ENetHost* host, ENetEvent* event);
bool SendPacket(ENetPeer* socket, const sf::Packet& packet, u8 channel_id);
} // namespace Common::ENet