fixed memory leak in config of msgService

This commit is contained in:
csoler 2017-03-04 20:52:06 +01:00
parent 2302c46ee4
commit 7111579954

View file

@ -587,7 +587,6 @@ bool p3MsgService::loadList(std::list<RsItem*>& load)
// load items and calculate next unique msgId // load items and calculate next unique msgId
for(it = load.begin(); it != load.end(); ++it) for(it = load.begin(); it != load.end(); ++it)
{ {
if (NULL != (mitem = dynamic_cast<RsMsgItem *>(*it))) if (NULL != (mitem = dynamic_cast<RsMsgItem *>(*it)))
{ {
/* STORE MsgID */ /* STORE MsgID */
@ -599,19 +598,23 @@ bool p3MsgService::loadList(std::list<RsItem*>& load)
else if (NULL != (grm = dynamic_cast<RsMsgGRouterMap *>(*it))) else if (NULL != (grm = dynamic_cast<RsMsgGRouterMap *>(*it)))
{ {
// merge. // merge.
for(std::map<GRouterMsgPropagationId,uint32_t>::const_iterator it(grm->ongoing_msgs.begin());it!=grm->ongoing_msgs.end();++it) for(std::map<GRouterMsgPropagationId,uint32_t>::const_iterator bit(grm->ongoing_msgs.begin());bit!=grm->ongoing_msgs.end();++bit)
_ongoing_messages.insert(*it) ; _ongoing_messages.insert(*bit) ;
delete *it ;
continue ;
} }
else if(NULL != (ghm = dynamic_cast<RsMsgDistantMessagesHashMap*>(*it))) else if(NULL != (ghm = dynamic_cast<RsMsgDistantMessagesHashMap*>(*it)))
{ {
mRecentlyReceivedDistantMessageHashes = ghm->hash_map ; mRecentlyReceivedDistantMessageHashes = ghm->hash_map ;
#ifdef DEBUG_DISTANT_MSG #ifdef DEBUG_DISTANT_MSG
std::cerr << " loaded recently received message map: " << std::endl; std::cerr << " loaded recently received message map: " << std::endl;
for(std::map<Sha1CheckSum,uint32_t>::const_iterator it(mRecentlyReceivedDistantMessageHashes.begin());it!=mRecentlyReceivedDistantMessageHashes.end();++it) for(std::map<Sha1CheckSum,uint32_t>::const_iterator it(mRecentlyReceivedDistantMessageHashes.begin());it!=mRecentlyReceivedDistantMessageHashes.end();++it)
std::cerr << " " << it->first << " received " << time(NULL)-it->second << " secs ago." << std::endl; std::cerr << " " << it->first << " received " << time(NULL)-it->second << " secs ago." << std::endl;
#endif #endif
delete *it ;
continue ;
} }
else if(NULL != (mtt = dynamic_cast<RsMsgTagType *>(*it))) else if(NULL != (mtt = dynamic_cast<RsMsgTagType *>(*it)))
{ {