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