Commit fdb7c272 authored by Ian McInerney's avatar Ian McInerney

Fixed various memory leaks

parent 01394f7f
......@@ -199,9 +199,6 @@ class CCrazyflie {
CTOC *m_tocLogs;
enum State m_enumState;
// Function to hold the received logging packets in
std::list<CCRTPPacket*> m_lstLoggingPackets;
// Flags to say whether to send packets
bool m_sendSetpoints;
bool m_sendPosition;
......
......@@ -488,7 +488,7 @@ CCRTPPacket *CCrazyRadio::sendAndReceive(CCRTPPacket *crtpSend,
if( ALL_THE_DEBUG ) printf( "Enter: %s(crtpSend:0x%08x,nRadioChannel:%d,nPort:%d,nChannel:%d,...)\n", __FUNCTION__, crtpSend, nRadioChannel, nPort, nChannel );
bool bGoon = true;
int nResendCounter = 0;
CCRTPPacket *crtpReturnvalue = NULL;
// CCRTPPacket *crtpReturnvalue = NULL;
CCRTPPacket *crtpReceived = NULL;
if( ALL_THE_DEBUG ) printf( "sendAndReceive for port %d, channel %d\n", nPort, nChannel );
......@@ -507,7 +507,7 @@ CCRTPPacket *CCrazyRadio::sendAndReceive(CCRTPPacket *crtpSend,
if (crtpReceived->port() == nPort
&& crtpReceived->channel() == nChannel) {
if( ALL_THE_DEBUG ) printf( "right port and channel\n" );
crtpReturnvalue = crtpReceived;
// crtpReturnvalue = crtpReceived;
bGoon = false;
}
else
......@@ -530,7 +530,8 @@ CCRTPPacket *CCrazyRadio::sendAndReceive(CCRTPPacket *crtpSend,
}
if( ALL_THE_DEBUG ) printf( "Exit: %s\n", __FUNCTION__ );
return crtpReturnvalue;
//return crtpReturnvalue;
return crtpReceived;
}
/*
std::list<CCRTPPacket*> CCrazyRadio::popLoggingPackets() {
......
......@@ -74,6 +74,7 @@ bool CTOC::requestMetaData() {
}
delete crtpReceived;
delete crtpPacket;
return bReturnvalue;
}
......@@ -102,6 +103,7 @@ bool CTOC::requestItem(int nID, bool bInitial) {
bReturnvalue = this->processItem(crtpReceived);
delete crtpReceived;
delete crtpPacket;
return bReturnvalue;
}
......@@ -241,6 +243,8 @@ bool CTOC::startLogging(std::string strName, std::string strBlockName) {
CCRTPPacket* crtpReceived = m_crRadio->sendAndReceive(
crtpLogVariable, m_nRadioChannel, m_crazyflie);
delete crtpLogVariable;
char* cData = crtpReceived->data();
bool bCreateOK = false;
if (cData[0] == 0x01 && cData[1] == lbCurrent.nID
......@@ -393,6 +397,8 @@ bool CTOC::registerLoggingBlock(std::string strName, double dFrequency) {
CCRTPPacket* crtpReceived = m_crRadio->sendAndReceive(crtpRegisterBlock, m_nRadioChannel, m_crazyflie);
delete crtpRegisterBlock;
char* cData = crtpReceived->data();
bool bCreateOK = false;
if (cData[0] == 0x00 && cData[1] == nID && cData[2] == 0x00) {
......@@ -438,6 +444,7 @@ bool CTOC::enableLogging(std::string strBlockName) {
crtpEnable->setChannel(1);
CCRTPPacket* crtpReceived = m_crRadio->sendAndReceive(crtpEnable, m_nRadioChannel, m_crazyflie);
delete crtpEnable;
delete crtpReceived;
return true;
......@@ -468,6 +475,8 @@ bool CTOC::unregisterLoggingBlockID(int nID) {
CCRTPPacket* crtpReceived = m_crRadio->sendAndReceive(crtpUnregisterBlock, m_nRadioChannel, m_crazyflie);
delete crtpUnregisterBlock;
if (crtpReceived) {
delete crtpReceived;
return true;
......
......@@ -112,7 +112,8 @@ CCrazyflie::CCrazyflie(CCrazyRadio *crRadio, int nRadioChannel, int quadNum, dou
}
CCrazyflie::~CCrazyflie() {
delete m_tocParameters;
delete m_tocLogs;
}
bool CCrazyflie::sendSetpoint(float fRoll, float fPitch, float fYaw,
......
......@@ -96,6 +96,8 @@ void CCrazyflie::callback_Packet(CCRTPPacket *crtpPacket) {
crtpLog->setPort(crtpPacket->port());
m_tocLogs->processPackets(crtpLog);
delete crtpLog;
}
break;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment