minisat: Check for gcc

This commit is contained in:
Krystine Sherwin 2024-08-16 04:30:37 +12:00
parent eb02ab07da
commit 55307a5452
No known key found for this signature in database
1 changed files with 7 additions and 1 deletions

View File

@ -100,7 +100,13 @@ void vec<T,_Size>::capacity(Size min_cap) {
Size add = max((min_cap - cap + 1) & ~1, ((cap >> 1) + 2) & ~1); // NOTE: grow by approximately 3/2
const Size size_max = std::numeric_limits<Size>::max();
if ( ((size_max <= std::numeric_limits<int>::max()) && (add > size_max - cap))
|| (((data = (T*)::reallocarray(data, (cap += add), sizeof(T))) == NULL) && errno == ENOMEM) )
|| (
#ifdef _DEFAULT_SOURCE
((data = (T*)::reallocarray(data, (cap += add), sizeof(T))) == NULL)
#else
((data = (T*)::realloc(data, (cap += add) * sizeof(T))) == NULL)
#endif
&& errno == ENOMEM) )
throw OutOfMemoryException();
}