From 07ac945794ff7a70f46e87a473c49aca7a515de6 Mon Sep 17 00:00:00 2001 From: gereon Date: Tue, 4 Dec 2012 21:43:53 +0100 Subject: [PATCH] some more documentation also call delete for objects created in parsers as you can see, this is kind of ugly, maybe we should use a different structure there... --- src/mrmc.cpp | 3 +++ src/parser/readLabFile.cpp | 1 + src/parser/readLabFile.h | 4 ++++ src/parser/readTraFile.cpp | 1 + src/parser/readTraFile.h | 5 ++++- 5 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/mrmc.cpp b/src/mrmc.cpp index 252d6dcc1..932673be4 100644 --- a/src/mrmc.cpp +++ b/src/mrmc.cpp @@ -106,6 +106,9 @@ int main(const int argc, const char* argv[]) { if (s != nullptr) { delete s; } + + delete labparser.getLabeling(); + delete traparser.getMatrix(); LOG4CPLUS_INFO(logger, "Nothing more to do, exiting."); diff --git a/src/parser/readLabFile.cpp b/src/parser/readLabFile.cpp index 87602652b..ba56c44a0 100644 --- a/src/parser/readLabFile.cpp +++ b/src/parser/readLabFile.cpp @@ -46,6 +46,7 @@ namespace parser { * @return The pointer to the created labeling object. */ LabParser::LabParser(uint_fast64_t node_count, const char * filename) + : labeling(nullptr) { /* * open file diff --git a/src/parser/readLabFile.h b/src/parser/readLabFile.h index c5cd029f6..67aec1178 100644 --- a/src/parser/readLabFile.h +++ b/src/parser/readLabFile.h @@ -11,11 +11,15 @@ namespace parser { /*! * @brief Load label file and return initialized AtomicPropositionsLabeling object. + * + * Note that this class creates a new AtomicPropositionsLabeling object that can + * be accessed via getLabeling(). However, it will not delete this object! */ class LabParser : Parser { public: LabParser(uint_fast64_t node_count, const char* filename); + mrmc::models::AtomicPropositionsLabeling* getLabeling() { return this->labeling; diff --git a/src/parser/readTraFile.cpp b/src/parser/readTraFile.cpp index 45ed6e20b..0871bfebd 100644 --- a/src/parser/readTraFile.cpp +++ b/src/parser/readTraFile.cpp @@ -118,6 +118,7 @@ uint_fast32_t TraParser::firstPass(char* buf, uint_fast32_t &maxnode) */ TraParser::TraParser(const char * filename) + : matrix(nullptr) { /* * enforce locale where decimal point is '.' diff --git a/src/parser/readTraFile.h b/src/parser/readTraFile.h index 813752db7..7ec735123 100644 --- a/src/parser/readTraFile.h +++ b/src/parser/readTraFile.h @@ -11,12 +11,15 @@ namespace parser { /*! * @brief Load transition system from file and return initialized * StaticSparseMatrix object. + * + * Note that this class creates a new StaticSparseMatrix object that can be + * accessed via getMatrix(). However, it does not delete this object! */ class TraParser : Parser { public: TraParser(const char* filename); - + mrmc::storage::SquareSparseMatrix* getMatrix() { return this->matrix;