mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 14:38:29 +01:00
Add a constant for the maximum vector allocation (5 Mbyte)
This commit is contained in:
@@ -25,6 +25,9 @@
|
|||||||
|
|
||||||
static const unsigned int MAX_SIZE = 0x02000000;
|
static const unsigned int MAX_SIZE = 0x02000000;
|
||||||
|
|
||||||
|
/** Maximum amount of memory (in bytes) to allocate at once when deserializing vectors. */
|
||||||
|
static const unsigned int MAX_VECTOR_ALLOCATE = 5000000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dummy data type to identify deserializing constructors.
|
* Dummy data type to identify deserializing constructors.
|
||||||
*
|
*
|
||||||
@@ -750,7 +753,7 @@ void Unserialize_impl(Stream& is, prevector<N, T>& v, const V&)
|
|||||||
unsigned int nMid = 0;
|
unsigned int nMid = 0;
|
||||||
while (nMid < nSize)
|
while (nMid < nSize)
|
||||||
{
|
{
|
||||||
nMid += 5000000 / sizeof(T);
|
nMid += MAX_VECTOR_ALLOCATE / sizeof(T);
|
||||||
if (nMid > nSize)
|
if (nMid > nSize)
|
||||||
nMid = nSize;
|
nMid = nSize;
|
||||||
v.resize_uninitialized(nMid);
|
v.resize_uninitialized(nMid);
|
||||||
@@ -830,7 +833,7 @@ void Unserialize_impl(Stream& is, std::vector<T, A>& v, const V&)
|
|||||||
unsigned int nMid = 0;
|
unsigned int nMid = 0;
|
||||||
while (nMid < nSize)
|
while (nMid < nSize)
|
||||||
{
|
{
|
||||||
nMid += 5000000 / sizeof(T);
|
nMid += MAX_VECTOR_ALLOCATE / sizeof(T);
|
||||||
if (nMid > nSize)
|
if (nMid > nSize)
|
||||||
nMid = nSize;
|
nMid = nSize;
|
||||||
v.resize(nMid);
|
v.resize(nMid);
|
||||||
|
|||||||
Reference in New Issue
Block a user