From 37d800bea016d5cba5635db036f53a486614ed30 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Wed, 6 Sep 2017 11:25:03 -0700 Subject: Add a constant for the maximum vector allocation (5 Mbyte) --- src/serialize.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/serialize.h') diff --git a/src/serialize.h b/src/serialize.h index 7fa669ebdb..8161f6c91f 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& 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& 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); -- cgit v1.2.3