mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-12 03:39:01 +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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user