Abort instead of throwing on oom

This commit is contained in:
Jesse Jones 2012-12-11 19:16:00 -08:00 committed by Brian Anderson
parent e8d2d55900
commit 0402360abb

View File

@ -72,8 +72,10 @@ array_list<T>::push(T value) {
if (_size == _capacity) {
size_t new_capacity = _capacity * 2;
void* buffer = realloc(_data, new_capacity * sizeof(T));
if (buffer == NULL)
throw std::bad_alloc();
if (buffer == NULL) {
fprintf(stderr, "array_list::push> Out of memory allocating %ld bytes", new_capacity * sizeof(T));
abort();
}
_data = (T *) buffer;
_capacity = new_capacity;
}