mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Fix base_uint ctor to disambiguate void const*
This commit is contained in:
3
TODO.txt
3
TODO.txt
@@ -14,6 +14,9 @@ Vinnie's Short List (Changes day to day)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
- Use static creation member functions instead of endless constructor
|
||||
variations in base_uint, uint256, and family.
|
||||
|
||||
- Take away the "I" prefix from abstract interface classes, in both the class
|
||||
name and the file name. It is messing up sorting in the IDE. Use "Imp" or
|
||||
suffix for implementations.
|
||||
|
||||
@@ -176,7 +176,7 @@ public:
|
||||
else
|
||||
{
|
||||
// Uh oh, corrupted data!
|
||||
WriteLog (lsFATAL, NodeObject) << "Corrupt NodeObject #" << uint256 (it->key ().data ());
|
||||
WriteLog (lsFATAL, NodeObject) << "Corrupt NodeObject #" << uint256::fromVoid (it->key ().data ());
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
|
||||
Status fetch (void const* key, NodeObject::Ptr* pObject)
|
||||
{
|
||||
uint256 const hash (key);
|
||||
uint256 const hash (uint256::fromVoid (key));
|
||||
|
||||
Map::iterator iter = m_map.find (hash);
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ NodeObject::Ptr NodeStore::DecodedBlob::createObject ()
|
||||
memcpy (data.data (), m_objectData, m_dataBytes);
|
||||
|
||||
object = NodeObject::createObject (
|
||||
m_objectType, m_ledgerIndex, data, uint256 (m_key));
|
||||
m_objectType, m_ledgerIndex, data, uint256::fromVoid (m_key));
|
||||
}
|
||||
|
||||
return object;
|
||||
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
{
|
||||
ScopedLock sl (m_db->getDBLock());
|
||||
|
||||
uint256 const hash (key);
|
||||
uint256 const hash (uint256::fromVoid (key));
|
||||
|
||||
static SqliteStatement pSt (m_db->getDB()->getSqliteDB(),
|
||||
"SELECT ObjType,LedgerIndex,Object FROM CommittedObjects WHERE Hash = ?;");
|
||||
|
||||
@@ -38,17 +38,22 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
// This is to disambiguate from other 1 parameter ctors
|
||||
struct FromVoid { };
|
||||
|
||||
/** Construct from a raw pointer.
|
||||
|
||||
The buffer pointed to by `data` must be at least 32 bytes.
|
||||
*/
|
||||
explicit base_uint (void const* data)
|
||||
base_uint (void const* data, FromVoid)
|
||||
{
|
||||
// BITS must be a multiple of 32
|
||||
static_bassert ((BITS % 32) == 0);
|
||||
|
||||
memcpy (&pn [0], data, BITS / 8);
|
||||
}
|
||||
public:
|
||||
|
||||
bool isZero () const
|
||||
{
|
||||
@@ -504,10 +509,16 @@ public:
|
||||
*this = b;
|
||||
}
|
||||
|
||||
explicit uint256 (void const* data)
|
||||
: base_uint256 (data)
|
||||
private:
|
||||
uint256 (void const* data, FromVoid)
|
||||
: base_uint256 (data, FromVoid ())
|
||||
{
|
||||
}
|
||||
public:
|
||||
static uint256 fromVoid (void const* data)
|
||||
{
|
||||
return uint256 (data, FromVoid ());
|
||||
}
|
||||
|
||||
uint256& operator= (uint64 uHost)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user