aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/ext/mt_allocator.h
diff options
context:
space:
mode:
authorPaolo Carlini <pcarlini@suse.de>2004-10-21 00:06:02 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2004-10-21 00:06:02 +0000
commita063e891bd88967d9dcea0f8c163f8372116265f (patch)
tree86541239e0f24c6b8ccdb784b4212770c4b0f617 /libstdc++-v3/include/ext/mt_allocator.h
parentf644cebf003c3dade9b0b583facc5c8d50a025f3 (diff)
downloadgcc-a063e891bd88967d9dcea0f8c163f8372116265f.zip
gcc-a063e891bd88967d9dcea0f8c163f8372116265f.tar.gz
gcc-a063e891bd88967d9dcea0f8c163f8372116265f.tar.bz2
bitmap_allocator.h (allocate): Throw std::bad_alloc when n > max_size().
2004-10-20 Paolo Carlini <pcarlini@suse.de> * include/ext/bitmap_allocator.h (allocate): Throw std::bad_alloc when n > max_size(). * include/ext/malloc_allocator.h (allocate): Likewise. * include/ext/mt_allocator.h (allocate): Likewise. * include/ext/new_allocator.h (allocate): Likewise. * include/ext/array_allocator.h: Use __throw_bad_alloc(). * include/ext/pool_allocator.h: Use __builtin_expect. * testsuite/ext/array_allocator/check_allocate_max_size.cc: New. * testsuite/ext/bitmap_allocator/check_allocate_max_size.cc: Likewise. * testsuite/ext/malloc_allocator/check_allocate_max_size.cc: Likewise. * testsuite/ext/mt_allocator/check_allocate_max_size.cc: Likewise. * testsuite/ext/new_allocator/check_allocate_max_size.cc: Likewise. * testsuite/ext/pool_allocator/check_allocate_max_size.cc: Likewise. * testsuite/testsuite_allocator.h (check_allocate_max_size): New test. From-SVN: r89351
Diffstat (limited to 'libstdc++-v3/include/ext/mt_allocator.h')
-rw-r--r--libstdc++-v3/include/ext/mt_allocator.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/libstdc++-v3/include/ext/mt_allocator.h b/libstdc++-v3/include/ext/mt_allocator.h
index 5e587ad..6649111 100644
--- a/libstdc++-v3/include/ext/mt_allocator.h
+++ b/libstdc++-v3/include/ext/mt_allocator.h
@@ -685,6 +685,9 @@ namespace __gnu_cxx
{
this->_S_initialize_once();
+ if (__builtin_expect(__n > this->max_size(), false))
+ std::__throw_bad_alloc();
+
// Requests larger than _M_max_bytes are handled by operator
// new/delete directly.
__pool_type& __pool = this->_S_get_pool();
@@ -694,7 +697,7 @@ namespace __gnu_cxx
void* __ret = ::operator new(__bytes);
return static_cast<_Tp*>(__ret);
}
-
+
// Round up to power of 2 and figure out which bin to use.
const size_t __which = __pool._M_get_binmap(__bytes);
const size_t __thread_id = __pool._M_get_thread_id();