From a8d911c021c92d424882003cf22cf4e154ec5ea2 Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Wed, 11 Jul 2012 14:40:43 +0200 Subject: Don't manage memory manually for the commasepstream in irc::portparser --- include/hashcomp.h | 6 +----- src/hashcomp.cpp | 13 ++++--------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/include/hashcomp.h b/include/hashcomp.h index 36d45dc64..59986e66f 100644 --- a/include/hashcomp.h +++ b/include/hashcomp.h @@ -441,7 +441,7 @@ namespace irc /** Used to split on commas */ - commasepstream* sep; + commasepstream sep; /** Current position in a range of ports */ @@ -475,10 +475,6 @@ namespace irc */ portparser(const std::string &source, bool allow_overlapped = true); - /** Frees the internal commasepstream object - */ - ~portparser(); - /** Fetch the next token from the stream * @return The next port number is returned, or 0 if none remain */ diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp index 3a478bb20..2275a1006 100644 --- a/src/hashcomp.cpp +++ b/src/hashcomp.cpp @@ -483,14 +483,9 @@ std::string& irc::stringjoiner::GetJoined() return joined; } -irc::portparser::portparser(const std::string &source, bool allow_overlapped) : in_range(0), range_begin(0), range_end(0), overlapped(allow_overlapped) +irc::portparser::portparser(const std::string &source, bool allow_overlapped) + : sep(source), in_range(0), range_begin(0), range_end(0), overlapped(allow_overlapped) { - sep = new irc::commasepstream(source); -} - -irc::portparser::~portparser() -{ - delete sep; } bool irc::portparser::Overlaps(long val) @@ -526,14 +521,14 @@ long irc::portparser::GetToken() } std::string x; - sep->GetToken(x); + sep.GetToken(x); if (x.empty()) return 0; while (Overlaps(atoi(x.c_str()))) { - if (!sep->GetToken(x)) + if (!sep.GetToken(x)) return 0; } -- cgit v1.2.3