From 4362a50705698f406c3be41a56b11a4ca8691f37 Mon Sep 17 00:00:00 2001 From: macbishop Date: Mon, 20 Sep 2004 17:05:15 +0000 Subject: [PATCH] Recommit because something is strange. The changes are that memory allocated in _construct is deallocated when the CmdLine obj is destroyed --- include/tclap/CommandLine.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/tclap/CommandLine.h b/include/tclap/CommandLine.h index 45660ea..1a2a8cc 100644 --- a/include/tclap/CommandLine.h +++ b/include/tclap/CommandLine.h @@ -93,6 +93,9 @@ class CmdLine */ XorHandler _xorHandler; + std::list _argDeleteOnExitList; + std::list _visitorDeleteOnExitList; + /** * Checks whether a name/flag string matches entirely matches * the Arg::blankChar. Used when multiple switches are combined @@ -122,6 +125,16 @@ class CmdLine */ void _constructor(); + /** + * Perform a delete ptr; operation on ptr when this object is deleted. + */ + void deleteOnExit(Arg* ptr); + + /** + * Perform a delete ptr; operation on ptr when this object is deleted. + */ + void deleteOnExit(Visitor* ptr); + public: /** @@ -151,6 +164,9 @@ class CmdLine CmdLine(const std::string& message, const char delimiter = ' ', const std::string& version = "none" ); + + ///Deletes any resources allocated by a CmdLine object + ~CmdLine(); /** * Adds an argument to the list of arguments to be parsed.