From 1b181b42b82213c884e8aac3a620252102992439 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Sat, 31 Oct 2020 23:21:15 +0000 Subject: Convert ConfigTag from reference<> to std::shared_ptr<>. --- src/configreader.cpp | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'src/configreader.cpp') diff --git a/src/configreader.cpp b/src/configreader.cpp index c70cafe25..d0b3e44c6 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -37,7 +37,7 @@ #include "configparser.h" #include -ServerLimits::ServerLimits(ConfigTag* tag) +ServerLimits::ServerLimits(std::shared_ptr tag) : MaxLine(tag->getUInt("maxline", 512, 512)) , NickMax(tag->getUInt("maxnick", 30, 1, MaxLine)) , ChanMax(tag->getUInt("maxchan", 64, 1, MaxLine)) @@ -52,7 +52,7 @@ ServerLimits::ServerLimits(ConfigTag* tag) { } -ServerConfig::ServerPaths::ServerPaths(ConfigTag* tag) +ServerConfig::ServerPaths::ServerPaths(std::shared_ptr tag) : Config(tag->getString("configdir", INSPIRCD_CONFIG_PATH, 1)) , Data(tag->getString("datadir", INSPIRCD_DATA_PATH, 1)) , Log(tag->getString("logdir", INSPIRCD_LOG_PATH, 1)) @@ -60,7 +60,7 @@ ServerConfig::ServerPaths::ServerPaths(ConfigTag* tag) { } -static ConfigTag* CreateEmptyTag() +static std::shared_ptr CreateEmptyTag() { ConfigItems* items; return ConfigTag::create("empty", "", 0, items); @@ -74,11 +74,6 @@ ServerConfig::ServerConfig() { } -ServerConfig::~ServerConfig() -{ - delete EmptyTag; -} - static void ReadXLine(ServerConfig* conf, const std::string& tag, const std::string& key, XLineFactory* make) { insp::flat_set configlines; @@ -103,7 +98,7 @@ static void ReadXLine(ServerConfig* conf, const std::string& tag, const std::str ServerInstance->XLines->ExpireRemovedConfigLines(make->GetType(), configlines); } -typedef std::map LocalIndex; +typedef std::map> LocalIndex; void ServerConfig::CrossCheckOperClassType() { LocalIndex operclass; @@ -188,7 +183,7 @@ void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current) { // No connect blocks found; make a trivial default block ConfigItems* items; - ConfigTag* tag = ConfigTag::create("connect", "", 0, items); + std::shared_ptr tag = ConfigTag::create("connect", "", 0, items); (*items)["allow"] = "*"; config_data.insert(std::make_pair("connect", tag)); blk_count = 1; @@ -348,9 +343,9 @@ static std::string GetServerName() void ServerConfig::Fill() { - ConfigTag* options = ConfValue("options"); - ConfigTag* security = ConfValue("security"); - ConfigTag* server = ConfValue("server"); + std::shared_ptr options = ConfValue("options"); + std::shared_ptr security = ConfValue("security"); + std::shared_ptr server = ConfValue("server"); if (sid.empty()) { ServerName = server->getString("name", GetServerName(), InspIRCd::IsHost); @@ -628,13 +623,13 @@ void ServerConfig::ApplyModules(User* user) } } -ConfigTag* ServerConfig::ConfValue(const std::string &tag) +std::shared_ptr ServerConfig::ConfValue(const std::string &tag) { std::pair found = config_data.equal_range(tag); if (found.first == found.second) return EmptyTag; - ConfigTag* rv = found.first->second; + std::shared_ptr rv = found.first->second; found.first++; if (found.first != found.second) ServerInstance->Logs.Log("CONFIG", LOG_DEFAULT, "Multiple <" + tag + "> tags found; only first will be used " -- cgit v1.3.1-10-gc9f91