From 43f3c51bce440f78a899c182526ccbfba47b2e0c Mon Sep 17 00:00:00 2001 From: "Daniel R. Carvalho" Date: Mon, 28 Dec 2020 11:01:41 -0300 Subject: [PATCH] sim: Make IniFile non-pointer in CheckpointIn There is no need to use a pointer for this variable. Change-Id: I784c94c8b775880def8339df63540357c2078c7b Signed-off-by: Daniel R. Carvalho Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/38741 Tested-by: kokoro Reviewed-by: Giacomo Travaglini Maintainer: Giacomo Travaglini --- src/sim/serialize.cc | 17 ++++++----------- src/sim/serialize.hh | 7 ++----- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/sim/serialize.cc b/src/sim/serialize.cc index 93eaf2c1fb..014e50da68 100644 --- a/src/sim/serialize.cc +++ b/src/sim/serialize.cc @@ -49,7 +49,6 @@ #include #include -#include "base/inifile.hh" #include "base/trace.hh" #include "debug/Checkpoint.hh" @@ -155,18 +154,14 @@ CheckpointIn::dir() } CheckpointIn::CheckpointIn(const std::string &cpt_dir) - : db(new IniFile), _cptDir(setDir(cpt_dir)) + : db(), _cptDir(setDir(cpt_dir)) { std::string filename = getCptDir() + "/" + CheckpointIn::baseFilename; - if (!db->load(filename)) { + if (!db.load(filename)) { fatal("Can't load checkpoint file '%s'\n", filename); } } -CheckpointIn::~CheckpointIn() -{ - delete db; -} /** * @param section Here we mention the section we are looking for * (example: currentsection). @@ -179,7 +174,7 @@ CheckpointIn::~CheckpointIn() bool CheckpointIn::entryExists(const std::string §ion, const std::string &entry) { - return db->entryExists(section, entry); + return db.entryExists(section, entry); } /** * @param section Here we mention the section we are looking for @@ -195,18 +190,18 @@ bool CheckpointIn::find(const std::string §ion, const std::string &entry, std::string &value) { - return db->find(section, entry, value); + return db.find(section, entry, value); } bool CheckpointIn::sectionExists(const std::string §ion) { - return db->sectionExists(section); + return db.sectionExists(section); } void CheckpointIn::visitSection(const std::string §ion, IniFile::VisitSectionCallback cb) { - db->visitSection(section, cb); + db.visitSection(section, cb); } diff --git a/src/sim/serialize.hh b/src/sim/serialize.hh index 5bd59a467d..0acda3265b 100644 --- a/src/sim/serialize.hh +++ b/src/sim/serialize.hh @@ -60,21 +60,18 @@ #include "base/logging.hh" #include "sim/serialize_handlers.hh" -class IniFile; - typedef std::ostream CheckpointOut; class CheckpointIn { private: - - IniFile *db; + IniFile db; const std::string _cptDir; public: CheckpointIn(const std::string &cpt_dir); - ~CheckpointIn(); + ~CheckpointIn() = default; /** * @return Returns the current directory being used for creating