Fixed valgrind reported mem leaks
This commit is contained in:
parent
7f0ffd66e0
commit
baf709b24d
@ -26,6 +26,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
|
||||||
|
#include <google/protobuf/stubs/common.h>
|
||||||
|
|
||||||
extern const char* version;
|
extern const char* version;
|
||||||
extern const char* revision;
|
extern const char* revision;
|
||||||
extern ProtocolManager *OstProtocolManager;
|
extern ProtocolManager *OstProtocolManager;
|
||||||
@ -76,8 +78,11 @@ int main(int argc, char* argv[])
|
|||||||
mainWindow = new MainWindow;
|
mainWindow = new MainWindow;
|
||||||
mainWindow->show();
|
mainWindow->show();
|
||||||
exitCode = app.exec();
|
exitCode = app.exec();
|
||||||
|
|
||||||
delete mainWindow;
|
delete mainWindow;
|
||||||
delete appSettings;
|
delete appSettings;
|
||||||
|
delete OstProtocolManager;
|
||||||
|
google::protobuf::ShutdownProtobufLibrary();
|
||||||
|
|
||||||
return exitCode;
|
return exitCode;
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
|
|
||||||
#include "../common/protocolmanager.h"
|
#include "../common/protocolmanager.h"
|
||||||
|
|
||||||
|
#include <google/protobuf/stubs/common.h>
|
||||||
|
|
||||||
#ifdef Q_OS_UNIX
|
#ifdef Q_OS_UNIX
|
||||||
#include "signal.h"
|
#include <signal.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern ProtocolManager *OstProtocolManager;
|
extern ProtocolManager *OstProtocolManager;
|
||||||
@ -36,17 +38,21 @@ void cleanup(int /*signum*/)
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
int exitCode = 0;
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
Drone drone;
|
Drone *drone = new Drone();
|
||||||
OstProtocolManager = new ProtocolManager();
|
OstProtocolManager = new ProtocolManager();
|
||||||
|
|
||||||
app.setApplicationName(drone.objectName());
|
app.setApplicationName(drone->objectName());
|
||||||
|
|
||||||
if (argc > 1)
|
if (argc > 1)
|
||||||
myport = atoi(argv[1]);
|
myport = atoi(argv[1]);
|
||||||
|
|
||||||
if (!drone.init())
|
if (!drone->init())
|
||||||
exit(-1);
|
{
|
||||||
|
exitCode = -1;
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef Q_OS_UNIX
|
#ifdef Q_OS_UNIX
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
@ -58,14 +64,18 @@ int main(int argc, char *argv[])
|
|||||||
qDebug("Failed to install SIGINT handler. Cleanup may not happen!!!");
|
qDebug("Failed to install SIGINT handler. Cleanup may not happen!!!");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
drone.setWindowFlags(drone.windowFlags()
|
drone->setWindowFlags(drone->windowFlags()
|
||||||
| Qt::WindowMaximizeButtonHint
|
| Qt::WindowMaximizeButtonHint
|
||||||
| Qt::WindowMinimizeButtonHint);
|
| Qt::WindowMinimizeButtonHint);
|
||||||
drone.showMinimized();
|
drone->showMinimized();
|
||||||
app.exec();
|
exitCode = app.exec();
|
||||||
|
|
||||||
|
_exit:
|
||||||
|
delete drone;
|
||||||
delete OstProtocolManager;
|
delete OstProtocolManager;
|
||||||
|
|
||||||
return 0;
|
google::protobuf::ShutdownProtobufLibrary();
|
||||||
|
|
||||||
|
return exitCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,6 +59,12 @@ LinuxPort::~LinuxPort()
|
|||||||
{
|
{
|
||||||
qDebug("In %s", __FUNCTION__);
|
qDebug("In %s", __FUNCTION__);
|
||||||
|
|
||||||
|
if (monitor_->isRunning())
|
||||||
|
{
|
||||||
|
monitor_->stop();
|
||||||
|
monitor_->wait();
|
||||||
|
}
|
||||||
|
|
||||||
if (clearPromisc_)
|
if (clearPromisc_)
|
||||||
{
|
{
|
||||||
int sd = socket(AF_INET, SOCK_DGRAM, 0);
|
int sd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||||
@ -114,6 +120,7 @@ bool LinuxPort::setExclusiveControl(bool /*exclusive*/)
|
|||||||
LinuxPort::StatsMonitor::StatsMonitor()
|
LinuxPort::StatsMonitor::StatsMonitor()
|
||||||
: QThread()
|
: QThread()
|
||||||
{
|
{
|
||||||
|
stop_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LinuxPort::StatsMonitor::run()
|
void LinuxPort::StatsMonitor::run()
|
||||||
@ -260,7 +267,7 @@ void LinuxPort::StatsMonitor::run()
|
|||||||
//
|
//
|
||||||
// We are all set - Let's start polling for stats!
|
// We are all set - Let's start polling for stats!
|
||||||
//
|
//
|
||||||
while (1)
|
while (!stop_)
|
||||||
{
|
{
|
||||||
lseek(fd, 0, SEEK_SET);
|
lseek(fd, 0, SEEK_SET);
|
||||||
len = read(fd, (void*) buf.data(), buf.size());
|
len = read(fd, (void*) buf.data(), buf.size());
|
||||||
@ -334,6 +341,12 @@ void LinuxPort::StatsMonitor::run()
|
|||||||
}
|
}
|
||||||
QThread::sleep(kRefreshFreq_);
|
QThread::sleep(kRefreshFreq_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(portStats);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LinuxPort::StatsMonitor::stop()
|
||||||
|
{
|
||||||
|
stop_ = true;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -44,8 +44,10 @@ protected:
|
|||||||
public:
|
public:
|
||||||
StatsMonitor();
|
StatsMonitor();
|
||||||
void run();
|
void run();
|
||||||
|
void stop();
|
||||||
private:
|
private:
|
||||||
static const int kRefreshFreq_ = 1; // in seconds
|
static const int kRefreshFreq_ = 1; // in seconds
|
||||||
|
bool stop_;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool clearPromisc_;
|
bool clearPromisc_;
|
||||||
|
@ -324,6 +324,8 @@ PcapPort::PortTransmitter::~PortTransmitter()
|
|||||||
{
|
{
|
||||||
if (usingInternalStats_)
|
if (usingInternalStats_)
|
||||||
delete stats_;
|
delete stats_;
|
||||||
|
if (usingInternalHandle_)
|
||||||
|
pcap_close(handle_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PcapPort::PortTransmitter::clearPacketList()
|
void PcapPort::PortTransmitter::clearPacketList()
|
||||||
|
Loading…
Reference in New Issue
Block a user