|
Boost-Commit : |
From: daniel_james_at_[hidden]
Date: 2008-01-20 12:37:22
Author: danieljames
Date: 2008-01-20 12:37:21 EST (Sun, 20 Jan 2008)
New Revision: 42881
URL: http://svn.boost.org/trac/boost/changeset/42881
Log:
Include <new> to get std::bad_alloc.
Text files modified:
trunk/libs/unordered/test/helpers/allocator.hpp | 9 +++++++--
trunk/libs/unordered/test/objects/exception.hpp | 1 +
2 files changed, 8 insertions(+), 2 deletions(-)
Modified: trunk/libs/unordered/test/helpers/allocator.hpp
==============================================================================
--- trunk/libs/unordered/test/helpers/allocator.hpp (original)
+++ trunk/libs/unordered/test/helpers/allocator.hpp 2008-01-20 12:37:21 EST (Sun, 20 Jan 2008)
@@ -9,6 +9,7 @@
#include <cstddef>
#include <cstdlib>
#include <boost/limits.hpp>
+#include <new>
#if defined(BOOST_MSVC)
#pragma warning(push)
@@ -39,7 +40,9 @@
pointer allocate(size_type n) {
using namespace std;
- return static_cast<T*>(malloc(n * sizeof(T)));
+ T* ptr = static_cast<T*>(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 @@
}
char* _Charalloc(size_type n) {
using namespace std;
- return static_cast<char*>(malloc(n * sizeof(char)));
+ T* ptr = static_cast<T*>(malloc(n * sizeof(char)));
+ if(!ptr) throw std::bad_alloc();
+ return ptr;
}
#endif
};
Modified: trunk/libs/unordered/test/objects/exception.hpp
==============================================================================
--- trunk/libs/unordered/test/objects/exception.hpp (original)
+++ trunk/libs/unordered/test/objects/exception.hpp 2008-01-20 12:37:21 EST (Sun, 20 Jan 2008)
@@ -11,6 +11,7 @@
#include <cstddef>
#include <iostream>
#include <boost/limits.hpp>
+#include <new>
#include "../helpers/fwd.hpp"
#include "../helpers/allocator.hpp"
#include "./memory.hpp"
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk