From bdac469ed33a4b36507b48bd5d01ec8e1a98d576 Mon Sep 17 00:00:00 2001 From: Luke De Mouy Date: Thu, 7 Jan 2016 03:39:50 -0700 Subject: [PATCH] remove unnecessary include, delete the QFile once we're done with it. Add in a constructor that initializes the port cache, and add in a destructor to delete the cache if portlookup is deleted. --- src/library/portlookup.cpp | 13 ++++++++++++- src/library/portlookup.h | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/library/portlookup.cpp b/src/library/portlookup.cpp index 6365b96..dfd12e4 100644 --- a/src/library/portlookup.cpp +++ b/src/library/portlookup.cpp @@ -1,6 +1,6 @@ #include "portlookup.h" #include -#include + using namespace sysadm; PortLookUp::PortInfo PortLookUp::LookUpPort(int portNumber) { @@ -67,6 +67,16 @@ PortLookUp::PortInfo PortLookUp::LookUpPort(int portNumber) } +PortLookUp::PortLookUp() +{ + readServiceFile(); +} + +PortLookUp::~PortLookUp() +{ + delete portStrings; +} + void PortLookUp::readServicesFile() { portStrings = new QStringList(); @@ -88,5 +98,6 @@ void PortLookUp::readServicesFile() portStrings->append(line); } services->close(); + delete services; } diff --git a/src/library/portlookup.h b/src/library/portlookup.h index 9638ba1..4ac4c9b 100644 --- a/src/library/portlookup.h +++ b/src/library/portlookup.h @@ -30,6 +30,7 @@ public: * @ErrorConditions Port Number is set to -1 and a description of the error is stored in the description variable */ PortInfo LookUpPort(int portNumber); + ~PortLookUp(); private: void readServicesFile();