From 68f5afc9bef648859478278f5bc3b012b68bf7fc Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 20 Jan 2008 17:37:21 +0000 Subject: [PATCH] Include to get std::bad_alloc. [SVN r42881] --- test/helpers/allocator.hpp | 9 +++++++-- test/objects/exception.hpp | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/test/helpers/allocator.hpp b/test/helpers/allocator.hpp index b3ff6398..7da6eb8b 100644 --- a/test/helpers/allocator.hpp +++ b/test/helpers/allocator.hpp @@ -9,6 +9,7 @@ #include #include #include +#include #if defined(BOOST_MSVC) #pragma warning(push) @@ -39,7 +40,9 @@ namespace test pointer allocate(size_type n) { using namespace std; - return static_cast(malloc(n * sizeof(T))); + T* ptr = static_cast(malloc(n * sizeof(T))); + if(!ptr) throw std::bad_alloc(); + return ptr; } pointer allocate(size_type n, const_pointer u) { return allocate(n); } @@ -71,7 +74,9 @@ namespace test } char* _Charalloc(size_type n) { using namespace std; - return static_cast(malloc(n * sizeof(char))); + T* ptr = static_cast(malloc(n * sizeof(char))); + if(!ptr) throw std::bad_alloc(); + return ptr; } #endif }; diff --git a/test/objects/exception.hpp b/test/objects/exception.hpp index cd4f4b13..c9e4a030 100644 --- a/test/objects/exception.hpp +++ b/test/objects/exception.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #include "../helpers/fwd.hpp" #include "../helpers/allocator.hpp" #include "./memory.hpp"