Commit 8742534d by Alan Mishchenko

More compiler warnings.

parent 91aaff25
...@@ -99,7 +99,7 @@ template<class T> ...@@ -99,7 +99,7 @@ template<class T>
void vec<T>::capacity(int min_cap) { void vec<T>::capacity(int min_cap) {
if (cap >= min_cap) return; if (cap >= min_cap) return;
int add = imax((min_cap - cap + 1) & ~1, ((cap >> 1) + 2) & ~1); // NOTE: grow by approximately 3/2 int add = imax((min_cap - cap + 1) & ~1, ((cap >> 1) + 2) & ~1); // NOTE: grow by approximately 3/2
if (add > INT_MAX - cap || (((data = (T*)::realloc(data, (cap += add) * sizeof(T))) == NULL) && errno == ENOMEM)) if (add > INT_MAX - cap || (((data = (T*)::realloc((void*)data, (cap += add) * sizeof(T))) == NULL) && errno == ENOMEM))
throw OutOfMemoryException(); throw OutOfMemoryException();
} }
......
...@@ -101,14 +101,14 @@ template<class T> ...@@ -101,14 +101,14 @@ template<class T>
void vec<T>::capacity(int min_cap) { void vec<T>::capacity(int min_cap) {
if (cap >= min_cap) return; if (cap >= min_cap) return;
int add = imax((min_cap - cap + 1) & ~1, ((cap >> 1) + 2) & ~1); // NOTE: grow by approximately 3/2 int add = imax((min_cap - cap + 1) & ~1, ((cap >> 1) + 2) & ~1); // NOTE: grow by approximately 3/2
if (add > INT_MAX - cap || (((data = (T*)::realloc(data, (cap += add) * sizeof(T))) == NULL) && errno == ENOMEM)) if (add > INT_MAX - cap || (((data = (T*)::realloc((void*)data, (cap += add) * sizeof(T))) == NULL) && errno == ENOMEM))
throw OutOfMemoryException(); throw OutOfMemoryException();
} }
template<class T> template<class T>
void vec<T>::prelocate(int ext_cap) { void vec<T>::prelocate(int ext_cap) {
if (cap >= ext_cap) return; if (cap >= ext_cap) return;
if (ext_cap > INT_MAX || (((data = (T*)::realloc(data, ext_cap * sizeof(T))) == NULL) && errno == ENOMEM)) if (ext_cap > INT_MAX || (((data = (T*)::realloc((void*)data, ext_cap * sizeof(T))) == NULL) && errno == ENOMEM))
throw OutOfMemoryException(); throw OutOfMemoryException();
cap = ext_cap; cap = ext_cap;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment