mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-11 11:19:02 +08:00
Bound pre-allocation to the maximal size representable by StorageIndex and throw bad_alloc if that's not possible.
This commit is contained in:
parent
2f6f8bf31c
commit
5ffe29cb9f
@ -86,7 +86,12 @@ class CompressedStorage
|
|||||||
void resize(Index size, double reserveSizeFactor = 0)
|
void resize(Index size, double reserveSizeFactor = 0)
|
||||||
{
|
{
|
||||||
if (m_allocatedSize<size)
|
if (m_allocatedSize<size)
|
||||||
reallocate(size + Index(reserveSizeFactor*double(size)));
|
{
|
||||||
|
Index realloc_size = (std::min<Index>)(NumTraits<StorageIndex>::highest(), size + Index(reserveSizeFactor*double(size)));
|
||||||
|
if(realloc_size<size)
|
||||||
|
internal::throw_std_bad_alloc();
|
||||||
|
reallocate(realloc_size);
|
||||||
|
}
|
||||||
m_size = size;
|
m_size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user