mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Misc: Minor change to make_unique_ptr_with_deleter to make it accept only pointers
This commit is contained in:
@@ -68,7 +68,7 @@ bool Ed25519::LoadFromFile(std::string const& fileName)
|
||||
_key = nullptr;
|
||||
}
|
||||
|
||||
auto keyBIO = make_unique_ptr_with_deleter(BIO_new_file(fileName.c_str(), "r"), BIO_free);
|
||||
auto keyBIO = make_unique_ptr_with_deleter(BIO_new_file(fileName.c_str(), "r"), &BIO_free);
|
||||
if (!keyBIO)
|
||||
return false;
|
||||
|
||||
@@ -89,7 +89,7 @@ bool Ed25519::LoadFromString(std::string const& keyPem)
|
||||
|
||||
auto keyBIO = make_unique_ptr_with_deleter(BIO_new_mem_buf(
|
||||
const_cast<char*>(keyPem.c_str()) /*api hack - this function assumes memory is readonly but lacks const modifier*/,
|
||||
keyPem.length() + 1), BIO_free);
|
||||
keyPem.length() + 1), &BIO_free);
|
||||
if (!keyBIO)
|
||||
return false;
|
||||
|
||||
|
||||
@@ -429,7 +429,7 @@ bool RsaSignature::LoadKeyFromFile(std::string const& fileName)
|
||||
_key = nullptr;
|
||||
}
|
||||
|
||||
auto keyBIO = make_unique_ptr_with_deleter(BIO_new_file(fileName.c_str(), "r"), BIO_free);
|
||||
auto keyBIO = make_unique_ptr_with_deleter(BIO_new_file(fileName.c_str(), "r"), &BIO_free);
|
||||
if (!keyBIO)
|
||||
return false;
|
||||
|
||||
@@ -450,7 +450,7 @@ bool RsaSignature::LoadKeyFromString(std::string const& keyPem)
|
||||
|
||||
auto keyBIO = make_unique_ptr_with_deleter(BIO_new_mem_buf(
|
||||
const_cast<char*>(keyPem.c_str()) /*api hack - this function assumes memory is readonly but lacks const modifier*/,
|
||||
keyPem.length() + 1), BIO_free);
|
||||
keyPem.length() + 1), &BIO_free);
|
||||
if (!keyBIO)
|
||||
return false;
|
||||
|
||||
@@ -466,7 +466,7 @@ bool RsaSignature::Sign(uint8 const* message, std::size_t messageLength, DigestG
|
||||
std::unique_ptr<EVP_MD, DigestGenerator::EVP_MD_Deleter> digestGenerator = generator.GetGenerator();
|
||||
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
|
||||
auto keyCtx = make_unique_ptr_with_deleter(EVP_PKEY_CTX_new_from_pkey(generator.GetLib(), _key, nullptr), EVP_PKEY_CTX_free);
|
||||
auto keyCtx = make_unique_ptr_with_deleter(EVP_PKEY_CTX_new_from_pkey(generator.GetLib(), _key, nullptr), &EVP_PKEY_CTX_free);
|
||||
EVP_MD_CTX_set_pkey_ctx(_ctx, keyCtx.get());
|
||||
|
||||
std::unique_ptr<OSSL_PARAM[]> params = generator.GetParams();
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Impl
|
||||
template<typename T, typename Del>
|
||||
struct unique_ptr_deleter
|
||||
{
|
||||
using pointer = T;
|
||||
using pointer = T*;
|
||||
unique_ptr_deleter(Del deleter) : _deleter(std::move(deleter)) { }
|
||||
|
||||
void operator()(pointer ptr) const { _deleter(ptr); }
|
||||
@@ -38,7 +38,7 @@ private:
|
||||
}
|
||||
|
||||
template<typename T, typename Del>
|
||||
auto make_unique_ptr_with_deleter(T ptr, Del&& deleter)
|
||||
auto make_unique_ptr_with_deleter(T* ptr, Del&& deleter)
|
||||
{
|
||||
using Deleter_t = Impl::unique_ptr_deleter<T, Del>;
|
||||
|
||||
|
||||
@@ -217,7 +217,7 @@ int main(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
auto sLoginServiceHandle = Trinity::make_unique_ptr_with_deleter(&dummy, [](void*) { sLoginService.StopNetwork(); });
|
||||
auto sLoginServiceHandle = Trinity::make_unique_ptr_with_deleter(&sLoginService, [](Battlenet::LoginRESTService* service) { service->StopNetwork(); });
|
||||
|
||||
// Start the listening port (acceptor) for auth connections
|
||||
int32 bnport = sConfigMgr->GetIntDefault("BattlenetPort", 1119);
|
||||
@@ -230,7 +230,7 @@ int main(int argc, char** argv)
|
||||
// Get the list of realms for the server
|
||||
sRealmList->Initialize(*ioContext, sConfigMgr->GetIntDefault("RealmsStateUpdateDelay", 10));
|
||||
|
||||
auto sRealmListHandle = Trinity::make_unique_ptr_with_deleter(&dummy, [](void*) { sRealmList->Close(); });
|
||||
auto sRealmListHandle = Trinity::make_unique_ptr_with_deleter(sRealmList, [](RealmList* realmList) { realmList->Close(); });
|
||||
|
||||
std::string bindIp = sConfigMgr->GetStringDefault("BindIP", "0.0.0.0");
|
||||
|
||||
@@ -240,7 +240,7 @@ int main(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
auto sSessionMgrHandle = Trinity::make_unique_ptr_with_deleter(&dummy, [](void*) { sSessionMgr.StopNetwork(); });
|
||||
auto sSessionMgrHandle = Trinity::make_unique_ptr_with_deleter(&sSessionMgr, [](Battlenet::SessionManager* sessMgr) { sessMgr->StopNetwork(); });
|
||||
|
||||
// Set signal handlers
|
||||
boost::asio::signal_set signals(*ioContext, SIGINT, SIGTERM);
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace
|
||||
{
|
||||
auto CreatePasswordUiMethodFromPemCallback(::pem_password_cb* callback)
|
||||
{
|
||||
return Trinity::make_unique_ptr_with_deleter(UI_UTIL_wrap_read_pem_callback(callback, 0), ::UI_destroy_method);
|
||||
return Trinity::make_unique_ptr_with_deleter(UI_UTIL_wrap_read_pem_callback(callback, 0), &::UI_destroy_method);
|
||||
}
|
||||
|
||||
auto OpenOpenSSLStore(boost::filesystem::path const& storePath, UI_METHOD const* passwordCallback, void* passwordCallbackData)
|
||||
@@ -45,7 +45,7 @@ auto OpenOpenSSLStore(boost::filesystem::path const& storePath, UI_METHOD const*
|
||||
|
||||
uri += genericPath;
|
||||
|
||||
return Trinity::make_unique_ptr_with_deleter(OSSL_STORE_open(uri.c_str(), passwordCallback, passwordCallbackData, nullptr, nullptr), ::OSSL_STORE_close);
|
||||
return Trinity::make_unique_ptr_with_deleter(OSSL_STORE_open(uri.c_str(), passwordCallback, passwordCallbackData, nullptr, nullptr), &::OSSL_STORE_close);
|
||||
}
|
||||
|
||||
boost::system::error_code GetLastOpenSSLError()
|
||||
|
||||
@@ -309,7 +309,7 @@ extern int main(int argc, char** argv)
|
||||
|
||||
sRealmList->Initialize(*ioContext, sConfigMgr->GetIntDefault("RealmsStateUpdateDelay", 10));
|
||||
|
||||
auto sRealmListHandle = Trinity::make_unique_ptr_with_deleter(&dummy, [](void*) { sRealmList->Close(); });
|
||||
auto sRealmListHandle = Trinity::make_unique_ptr_with_deleter(sRealmList, [](RealmList* realmList) { realmList->Close(); });
|
||||
|
||||
LoadRealmInfo();
|
||||
|
||||
@@ -323,34 +323,33 @@ extern int main(int argc, char** argv)
|
||||
|
||||
TC_METRIC_EVENT("events", "Worldserver started", "");
|
||||
|
||||
auto sMetricHandle = Trinity::make_unique_ptr_with_deleter(&dummy, [](void*)
|
||||
auto sMetricHandle = Trinity::make_unique_ptr_with_deleter(sMetric, [](Metric* metric)
|
||||
{
|
||||
TC_METRIC_EVENT("events", "Worldserver shutdown", "");
|
||||
sMetric->Unload();
|
||||
metric->Unload();
|
||||
});
|
||||
|
||||
auto scriptReloadMgrHandle = Trinity::make_unique_ptr_with_deleter(sScriptReloadMgr, [](ScriptReloadMgr* mgr) { mgr->Unload(); });
|
||||
|
||||
sScriptMgr->SetScriptLoader(AddScripts);
|
||||
auto sScriptMgrHandle = Trinity::make_unique_ptr_with_deleter(&dummy, [](void*)
|
||||
{
|
||||
sScriptMgr->Unload();
|
||||
sScriptReloadMgr->Unload();
|
||||
});
|
||||
auto sScriptMgrHandle = Trinity::make_unique_ptr_with_deleter(sScriptMgr, [](ScriptMgr* mgr) { mgr->Unload(); });
|
||||
|
||||
// Initialize the World
|
||||
sSecretMgr->Initialize(SECRET_OWNER_WORLDSERVER);
|
||||
if (!sWorld->SetInitialWorldSettings())
|
||||
return 1;
|
||||
|
||||
auto mapManagementHandle = Trinity::make_unique_ptr_with_deleter(&dummy, [](void*)
|
||||
{
|
||||
// unload battleground templates before different singletons destroyed
|
||||
sBattlegroundMgr->DeleteAllBattlegrounds();
|
||||
auto instanceLockMgrHandle = Trinity::make_unique_ptr_with_deleter(&sInstanceLockMgr, [](InstanceLockMgr* mgr) { mgr->Unload(); });
|
||||
|
||||
sMapMgr->UnloadAll(); // unload all grids (including locked in memory)
|
||||
sOutdoorPvPMgr->Die();
|
||||
sTerrainMgr.UnloadAll();
|
||||
sInstanceLockMgr.Unload();
|
||||
});
|
||||
auto terrainMgrHandle = Trinity::make_unique_ptr_with_deleter(&sTerrainMgr, [](TerrainMgr* mgr) { mgr->UnloadAll(); });
|
||||
|
||||
auto outdoorPvpMgrHandle = Trinity::make_unique_ptr_with_deleter(sOutdoorPvPMgr, [](OutdoorPvPMgr* mgr) { mgr->Die(); });
|
||||
|
||||
// unload all grids (including locked in memory)
|
||||
auto mapManagementHandle = Trinity::make_unique_ptr_with_deleter(sMapMgr, [](MapManager* mgr) { mgr->UnloadAll(); });
|
||||
|
||||
// unload battleground templates before different singletons destroyed
|
||||
auto battlegroundMgrHandle = Trinity::make_unique_ptr_with_deleter(sBattlegroundMgr, [](BattlegroundMgr* mgr) { mgr->DeleteAllBattlegrounds(); });
|
||||
|
||||
// Start the Remote Access port (acceptor) if enabled
|
||||
std::unique_ptr<AsyncAcceptor> raAcceptor;
|
||||
@@ -388,12 +387,12 @@ extern int main(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
auto sWorldSocketMgrHandle = Trinity::make_unique_ptr_with_deleter(&dummy, [](void*)
|
||||
auto sWorldSocketMgrHandle = Trinity::make_unique_ptr_with_deleter(&sWorldSocketMgr, [](WorldSocketMgr* mgr)
|
||||
{
|
||||
sWorld->KickAll(); // save and kick all players
|
||||
sWorld->UpdateSessions(1); // real players unload required UpdateSessions call
|
||||
|
||||
sWorldSocketMgr.StopNetwork();
|
||||
mgr->StopNetwork();
|
||||
|
||||
///- Clean database before leaving
|
||||
ClearOnlineAccounts();
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
std::thread* CreateSoapThread(const std::string& host, uint16 port)
|
||||
{
|
||||
auto soap = Trinity::make_unique_ptr_with_deleter<struct soap*>(new struct soap(), [](struct soap* soap)
|
||||
auto soap = Trinity::make_unique_ptr_with_deleter(new struct soap(), [](struct soap* soap)
|
||||
{
|
||||
soap_destroy(soap);
|
||||
soap_end(soap);
|
||||
|
||||
Reference in New Issue
Block a user