Pointer for GetStats() is now scoped rather than manually deleted.

This commit is contained in:
Ross Nicoll 2014-08-08 20:39:55 +01:00
parent 49c6e8a04f
commit 89fa1c237b

View file

@ -119,7 +119,7 @@ bool CBlockTreeDB::ReadLastBlockFile(int &nFile) {
} }
bool CCoinsViewDB::GetStats(CCoinsStats &stats) { bool CCoinsViewDB::GetStats(CCoinsStats &stats) {
leveldb::Iterator *pcursor = db.NewIterator(); boost::scoped_ptr<leveldb::Iterator> pcursor(db.NewIterator());
pcursor->SeekToFirst(); pcursor->SeekToFirst();
CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION); CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION);
@ -162,7 +162,7 @@ bool CCoinsViewDB::GetStats(CCoinsStats &stats) {
return error("%s : Deserialize or I/O error - %s", __func__, e.what()); return error("%s : Deserialize or I/O error - %s", __func__, e.what());
} }
} }
delete pcursor;
stats.nHeight = mapBlockIndex.find(GetBestBlock())->second->nHeight; stats.nHeight = mapBlockIndex.find(GetBestBlock())->second->nHeight;
stats.hashSerialized = ss.GetHash(); stats.hashSerialized = ss.GetHash();
stats.nTotalAmount = nTotalAmount; stats.nTotalAmount = nTotalAmount;