Merge pull request #94 from lbryio/fix_memory_leak

Fix memory leak
This commit is contained in:
Umpei Kay Kurokawa 2018-02-16 10:14:35 -05:00 committed by GitHub
commit dffd498152
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1220,14 +1220,24 @@ bool CClaimTrieCache::empty() const
CClaimTrieNode* CClaimTrieCache::addNodeToCache(const std::string& position, CClaimTrieNode* original) const
{
// create a copy of the node in the cache, if new node, create empty node
CClaimTrieNode* cacheCopy;
if(!original)
original = new CClaimTrieNode();
CClaimTrieNode* cacheCopy = new CClaimTrieNode(*original);
cacheCopy = new CClaimTrieNode();
else
cacheCopy = new CClaimTrieNode(*original);
cache[position] = cacheCopy;
// check to see if there is the original node in block_originals,
// if not, add it to block_originals cache
nodeCacheType::const_iterator itOriginals = block_originals.find(position);
if (block_originals.end() == itOriginals)
{
CClaimTrieNode* originalCopy = new CClaimTrieNode(*original);
CClaimTrieNode* originalCopy;
if(!original)
originalCopy = new CClaimTrieNode();
else
originalCopy = new CClaimTrieNode(*original);
block_originals[position] = originalCopy;
}
return cacheCopy;
@ -2457,6 +2467,7 @@ bool CClaimTrieCache::clear() const
supportCache.clear();
supportQueueCache.clear();
supportQueueNameCache.clear();
supportExpirationQueueCache.clear();
namesToCheckForTakeover.clear();
cacheTakeoverHeights.clear();
return true;