From 5595a404d0eb9e8a9972ff9dfbfe56809491872e Mon Sep 17 00:00:00 2001 From: adjoly Date: Mon, 14 Apr 2025 13:33:07 +0200 Subject: [PATCH] =?UTF-8?q?=E3=80=8C=F0=9F=8F=97=EF=B8=8F=E3=80=8D=20wip:?= =?UTF-8?q?=20added=20destructor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config/Config.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/config/Config.cpp b/src/config/Config.cpp index 650d5b3..277313f 100644 --- a/src/config/Config.cpp +++ b/src/config/Config.cpp @@ -6,27 +6,19 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/04/14 12:53:54 by adjoly #+# #+# */ -/* Updated: 2025/04/14 13:25:09 by adjoly ### ########.fr */ +/* Updated: 2025/04/14 13:32:56 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ -#include "cppeleven.hpp" -#include "node/ANode.hpp" #include -#include using namespace webserv::config; Config::Config(std::string &filename) { - toml::Toml file(filename); + toml::Toml *file = new toml::Toml(filename); - try { - file.parse(); - } catch (std::exception &e) { - throw e; - } - - _table = file.getParsedFile(); + file->parse(); + _table = file->getParsedFile(); bool found = false; void *logFile = _table->access("log_file", toml::STRING, found); @@ -42,4 +34,14 @@ Config::Config(std::string &filename) { Server *srv = new Server(it->second, _log); _servers->push_back(srv); } + delete _table; + delete file; +} + +Config::~Config(void) { + std::vector::iterator it = _servers->begin(); + for (; it != _servers->end() ; it++) { + delete *it; + } + delete _servers; }