diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2014-08-17 10:14:19 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2014-08-17 10:18:16 +0200 |
commit | b3ec053082c96233512c076eebc486b16a317b91 (patch) | |
tree | c8f5856c6d1e3e4c54579f353d5b5b9fd7d84a46 /src/txdb.cpp | |
parent | 27116e87ccc48421640458310cd6cab222fc27dd (diff) | |
parent | 5cbda4f10f16923910de2bd080152fc7bbc48738 (diff) | |
download | bitcoin-b3ec053082c96233512c076eebc486b16a317b91.tar.xz |
Merge pull request #4656
5cbda4f Changed LevelDB cursors to use scoped pointers to ensure destruction when going out of scope. (Ross Nicoll)
Diffstat (limited to 'src/txdb.cpp')
-rw-r--r-- | src/txdb.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/txdb.cpp b/src/txdb.cpp index 52cd96283e..d3d05c58d7 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -103,7 +103,7 @@ bool CBlockTreeDB::ReadLastBlockFile(int &nFile) { } bool CCoinsViewDB::GetStats(CCoinsStats &stats) { - leveldb::Iterator *pcursor = db.NewIterator(); + boost::scoped_ptr<leveldb::Iterator> pcursor(db.NewIterator()); pcursor->SeekToFirst(); CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION); @@ -146,7 +146,6 @@ bool CCoinsViewDB::GetStats(CCoinsStats &stats) { return error("%s : Deserialize or I/O error - %s", __func__, e.what()); } } - delete pcursor; stats.nHeight = mapBlockIndex.find(GetBestBlock())->second->nHeight; stats.hashSerialized = ss.GetHash(); stats.nTotalAmount = nTotalAmount; @@ -178,7 +177,7 @@ bool CBlockTreeDB::ReadFlag(const std::string &name, bool &fValue) { bool CBlockTreeDB::LoadBlockIndexGuts() { - leveldb::Iterator *pcursor = NewIterator(); + boost::scoped_ptr<leveldb::Iterator> pcursor(NewIterator()); CDataStream ssKeySet(SER_DISK, CLIENT_VERSION); ssKeySet << make_pair('b', uint256(0)); @@ -224,7 +223,6 @@ bool CBlockTreeDB::LoadBlockIndexGuts() return error("%s : Deserialize or I/O error - %s", __func__, e.what()); } } - delete pcursor; return true; } |