diff options
| author | Pieter Wuille <[email protected]> | 2017-09-06 11:25:03 -0700 |
|---|---|---|
| committer | Pieter Wuille <[email protected]> | 2020-01-29 20:56:05 -0800 |
| commit | 37d800bea016d5cba5635db036f53a486614ed30 (patch) | |
| tree | 45dfff1beb3c8bd4b42bf175a3d6c80b69541261 | |
| parent | Merge #17957: Serialization improvements step 3 (compression.h) (diff) | |
| download | discoin-37d800bea016d5cba5635db036f53a486614ed30.tar.xz discoin-37d800bea016d5cba5635db036f53a486614ed30.zip | |
Add a constant for the maximum vector allocation (5 Mbyte)
| -rw-r--r-- | src/serialize.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/serialize.h b/src/serialize.h index 7fa669ebd..8161f6c91 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -25,6 +25,9 @@ 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. * @@ -750,7 +753,7 @@ void Unserialize_impl(Stream& is, prevector<N, T>& v, const V&) unsigned int nMid = 0; while (nMid < nSize) { - nMid += 5000000 / sizeof(T); + nMid += MAX_VECTOR_ALLOCATE / sizeof(T); if (nMid > nSize) nMid = nSize; v.resize_uninitialized(nMid); @@ -830,7 +833,7 @@ void Unserialize_impl(Stream& is, std::vector<T, A>& v, const V&) unsigned int nMid = 0; while (nMid < nSize) { - nMid += 5000000 / sizeof(T); + nMid += MAX_VECTOR_ALLOCATE / sizeof(T); if (nMid > nSize) nMid = nSize; v.resize(nMid); |