aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2013-03-29 02:17:10 +0100
committerPieter Wuille <pieter.wuille@gmail.com>2013-03-29 02:24:18 +0100
commit3427517d507a938074a50fa8ea6dfe3d13bef357 (patch)
tree38ca3337c8c91e7a55423ca7f26fe5319f112085 /src/main.cpp
parentdfd71bb4509d12c26e630bc671a542ad5bab4945 (diff)
downloadbitcoin-3427517d507a938074a50fa8ea6dfe3d13bef357.tar.xz
Clean up global datastructures at shutdown.
This should make detecting leaks much easier.
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 22baf0f3eb..bde7b5acdb 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -4750,3 +4750,29 @@ uint64 CTxOutCompressor::DecompressAmount(uint64 x)
}
return n;
}
+
+
+class CMainCleanup
+{
+public:
+ CMainCleanup() {}
+ ~CMainCleanup() {
+ // block headers
+ std::map<uint256, CBlockIndex*>::iterator it1 = mapBlockIndex.begin();
+ for (; it1 != mapBlockIndex.end(); it1++)
+ delete (*it1).second;
+ mapBlockIndex.clear();
+
+ // orphan blocks
+ std::map<uint256, CBlock*>::iterator it2 = mapOrphanBlocks.begin();
+ for (; it2 != mapOrphanBlocks.end(); it2++)
+ delete (*it2).second;
+ mapOrphanBlocks.clear();
+
+ // orphan transactions
+ std::map<uint256, CDataStream*>::iterator it3 = mapOrphanTransactions.begin();
+ for (; it3 != mapOrphanTransactions.end(); it3++)
+ delete (*it3).second;
+ mapOrphanTransactions.clear();
+ }
+} instance_of_cmaincleanup;