mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-25 07:29:33 -05:00
* Fixed up various memory leaks (mainly serialiser cleanup).
* Added pthread_detach() to allow proper thread cleanup (affected ony Linux!) git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@460 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
e3df41b1da
commit
d69c2f72f1
@ -217,6 +217,7 @@ void stunPeer(std::string id, struct sockaddr_in peeraddr)
|
||||
|
||||
void *data = (void *) pub;
|
||||
pthread_create(&tid, 0, &doStunPeer, data);
|
||||
pthread_detach(tid);
|
||||
|
||||
return;
|
||||
|
||||
@ -361,6 +362,7 @@ int main(int argc, char **argv)
|
||||
|
||||
#endif
|
||||
|
||||
srand(time(NULL)); /* randomise! */
|
||||
|
||||
if (!setOwnId)
|
||||
{
|
||||
|
@ -179,6 +179,7 @@ bool OpenDHTMgr::publishDHT(std::string key, std::string value, uint32_t ttl)
|
||||
|
||||
void *data = (void *) pub;
|
||||
pthread_create(&tid, 0, &doDhtPublish, data);
|
||||
pthread_detach(tid); /* so memory is reclaimed in linux */
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -195,6 +196,7 @@ bool OpenDHTMgr::searchDHT(std::string key)
|
||||
|
||||
void *data = (void *) dht;
|
||||
pthread_create(&tid, 0, &doDhtSearch, data);
|
||||
pthread_detach(tid); /* so memory is reclaimed in linux */
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -185,6 +185,8 @@ void p3ConfigMgr::saveConfiguration()
|
||||
#endif
|
||||
}
|
||||
|
||||
delete signbio;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -332,6 +334,7 @@ void p3ConfigMgr::loadConfiguration()
|
||||
}
|
||||
}
|
||||
|
||||
delete item;
|
||||
|
||||
#ifdef CONFIG_DEBUG
|
||||
std::cerr << "p3ConfigMgr::loadConfiguration() Done!";
|
||||
|
@ -113,6 +113,9 @@ pqiarchive::~pqiarchive()
|
||||
delete bio;
|
||||
}
|
||||
|
||||
if (rsSerialiser)
|
||||
delete rsSerialiser;
|
||||
|
||||
if (nextPkt)
|
||||
{
|
||||
delete nextPkt;
|
||||
|
@ -88,6 +88,11 @@ BinFileInterface::~BinFileInterface()
|
||||
{
|
||||
fclose(buf);
|
||||
}
|
||||
|
||||
if (hash)
|
||||
{
|
||||
delete hash;
|
||||
}
|
||||
}
|
||||
|
||||
int BinFileInterface::close()
|
||||
@ -183,11 +188,14 @@ BinMemInterface::BinMemInterface(const void *data, const int defsize, int flags)
|
||||
}
|
||||
|
||||
BinMemInterface::~BinMemInterface()
|
||||
{
|
||||
if (buf)
|
||||
free(buf);
|
||||
return;
|
||||
}
|
||||
{
|
||||
if (buf)
|
||||
free(buf);
|
||||
|
||||
if (hash)
|
||||
delete hash;
|
||||
return;
|
||||
}
|
||||
|
||||
int BinMemInterface::close()
|
||||
{
|
||||
|
@ -40,6 +40,13 @@ class pqihash
|
||||
doHash = true;
|
||||
}
|
||||
|
||||
~pqihash()
|
||||
{
|
||||
delete[] sha_hash;
|
||||
delete sha_ctx;
|
||||
}
|
||||
|
||||
|
||||
void addData(void *data, uint32_t len)
|
||||
{
|
||||
if (doHash)
|
||||
@ -68,9 +75,6 @@ void Complete(std::string &hash)
|
||||
hash = endHash;
|
||||
doHash = false;
|
||||
|
||||
delete []sha_hash;
|
||||
delete sha_ctx;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -104,6 +104,10 @@ pqistreamer::~pqistreamer()
|
||||
delete bio;
|
||||
}
|
||||
|
||||
/* clean up serialiser */
|
||||
if (rsSerialiser)
|
||||
delete rsSerialiser;
|
||||
|
||||
// clean up outgoing. (cntrl packets)
|
||||
while(out_pkt.size() > 0)
|
||||
{
|
||||
|
@ -102,6 +102,7 @@ int RsServer::UpdateAllTransfers()
|
||||
ti.downloadStatus = (*it) -> state;
|
||||
transfers.push_back(ti);
|
||||
|
||||
delete (*it);
|
||||
}
|
||||
|
||||
iface.setChanged(RsIface::Transfer);
|
||||
|
@ -459,6 +459,7 @@ void p3Ranking::addRankMsg(RsRankLinkMsg *msg)
|
||||
}
|
||||
else
|
||||
{
|
||||
delete msg;
|
||||
#ifdef RANK_DEBUG
|
||||
std::cerr << "p3Ranking::addRankMsg() Old Comment ignoring";
|
||||
std::cerr << std::endl;
|
||||
|
Loading…
Reference in New Issue
Block a user