From 882c24d2ee9f71640bfc3be811b8dcddd91c9988 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sun, 3 May 2009 22:45:31 +0000 Subject: COMMON: Check for failed memory allocations; changed Common::String to use new/delete instead of malloc/free svn-id: r40291 --- common/array.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'common/array.h') diff --git a/common/array.h b/common/array.h index 7ac08efa92..ace5ce7e4b 100644 --- a/common/array.h +++ b/common/array.h @@ -54,6 +54,7 @@ public: Array(const Array &array) : _capacity(0), _size(0), _storage(0) { _capacity = _size = array._size; _storage = new T[_capacity]; + assert(_storage); copy(array._storage, array._storage + _size, _storage); } @@ -64,6 +65,7 @@ public: Array(const T2 *data, int n) { _capacity = _size = n; _storage = new T[_capacity]; + assert(_storage); copy(data, data + _size, _storage); } @@ -149,6 +151,7 @@ public: _size = array._size; _capacity = _size + 32; _storage = new T[_capacity]; + assert(_storage); copy(array._storage, array._storage + _size, _storage); return *this; @@ -193,6 +196,7 @@ public: T *old_storage = _storage; _capacity = newCapacity; _storage = new T[newCapacity]; + assert(_storage); if (old_storage) { // Copy old data -- cgit v1.2.3