remove unnecessary <string> 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.
This commit is contained in:
Luke De Mouy
2016-01-07 03:39:50 -07:00
committed by Luke Wolf
parent 19c072bc81
commit bdac469ed3
2 changed files with 13 additions and 1 deletions

View File

@@ -1,6 +1,6 @@
#include "portlookup.h"
#include <QtCore>
#include <string>
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;
}

View File

@@ -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();