mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-01-11 15:48:05 +00:00
Merge #11221: Refactor: simpler read
9db9d62
Refactor: make the read function simpler (gnuser)
Pull request description:
Tree-SHA512: 5a80cc1b841488323d421e6a40b245d149cab1988247aed6cc7468dcc042d3df15b6711f25e40ff16e03ac21de36adbaa1d8da61ccdb94f97c8b70c24a5eedc5
This commit is contained in:
commit
0dec4cc300
@ -345,18 +345,16 @@ public:
|
|||||||
|
|
||||||
// Read from the beginning of the buffer
|
// Read from the beginning of the buffer
|
||||||
unsigned int nReadPosNext = nReadPos + nSize;
|
unsigned int nReadPosNext = nReadPos + nSize;
|
||||||
if (nReadPosNext >= vch.size())
|
if (nReadPosNext > vch.size()) {
|
||||||
|
throw std::ios_base::failure("CDataStream::read(): end of data");
|
||||||
|
}
|
||||||
|
memcpy(pch, &vch[nReadPos], nSize);
|
||||||
|
if (nReadPosNext == vch.size())
|
||||||
{
|
{
|
||||||
if (nReadPosNext > vch.size())
|
|
||||||
{
|
|
||||||
throw std::ios_base::failure("CDataStream::read(): end of data");
|
|
||||||
}
|
|
||||||
memcpy(pch, &vch[nReadPos], nSize);
|
|
||||||
nReadPos = 0;
|
nReadPos = 0;
|
||||||
vch.clear();
|
vch.clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
memcpy(pch, &vch[nReadPos], nSize);
|
|
||||||
nReadPos = nReadPosNext;
|
nReadPos = nReadPosNext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user