Browse Source

Memleak fix: free genesis block at the end of program

cl-refactor
Paweł Bylica 10 years ago
parent
commit
d1fc535458
  1. 2
      libethereum/BlockChain.cpp
  2. 4
      libethereum/BlockChain.h

2
libethereum/BlockChain.cpp

@ -71,7 +71,7 @@ std::map<Address, Account> const& dev::eth::genesisState()
return s_ret;
}
BlockInfo* BlockChain::s_genesis = nullptr;
std::unique_ptr<BlockInfo> BlockChain::s_genesis;
boost::shared_mutex BlockChain::x_genesis;
ldb::Slice dev::eth::toSlice(h256 _h, unsigned _sub)

4
libethereum/BlockChain.h

@ -132,7 +132,7 @@ public:
h256Set allUnclesFrom(h256 _parent) const;
/// @returns the genesis block header.
static BlockInfo const& genesis() { UpgradableGuard l(x_genesis); if (!s_genesis) { auto gb = createGenesisBlock(); UpgradeGuard ul(l); (s_genesis = new BlockInfo)->populate(&gb); } return *s_genesis; }
static BlockInfo const& genesis() { UpgradableGuard l(x_genesis); if (!s_genesis) { auto gb = createGenesisBlock(); UpgradeGuard ul(l); s_genesis.reset(new BlockInfo); s_genesis->populate(&gb); } return *s_genesis; }
/// @returns the genesis block as its RLP-encoded byte array.
/// @note This is slow as it's constructed anew each call. Consider genesis() instead.
@ -211,7 +211,7 @@ private:
/// Static genesis info and its lock.
static boost::shared_mutex x_genesis;
static BlockInfo* s_genesis;
static std::unique_ptr<BlockInfo> s_genesis;
};
std::ostream& operator<<(std::ostream& _out, BlockChain const& _bc);

Loading…
Cancel
Save