uint256: Update constructors to c++11, make ONE static

Replace the memset with C++11 value/aggregate initialisation of
the m_data array, which still ensures the unspecified values end
up as zero-initialised.

This then allows changing UINT256_ONE() from dynamically allocating an
object, to a simpler referencing a static allocation.
This commit is contained in:
Anthony Towns
2020-09-25 15:01:38 +10:00
parent 78f912c901
commit 183f308fff
3 changed files with 17 additions and 11 deletions

View File

@@ -80,7 +80,4 @@ template std::string base_blob<256>::ToString() const;
template void base_blob<256>::SetHex(const char*);
template void base_blob<256>::SetHex(const std::string&);
uint256& UINT256_ONE() {
static uint256* one = new uint256(uint256S("0000000000000000000000000000000000000000000000000000000000000001"));
return *one;
}
const uint256 uint256::ONE(1);