diff options
author | bkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-06-01 10:09:40 +0000 |
---|---|---|
committer | bkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-06-01 10:09:40 +0000 |
commit | f9ca8b77ffddc3323e44e521a3ac31d3dc515c52 (patch) | |
tree | ee33ea2741f0a470133a6d3aaf97e5dd0337bd6f /libstdc++-v3/include | |
parent | ca2e246e7b95cbd28b244310d4b84201054d7491 (diff) | |
download | ppe42-gcc-f9ca8b77ffddc3323e44e521a3ac31d3dc515c52.tar.gz ppe42-gcc-f9ca8b77ffddc3323e44e521a3ac31d3dc515c52.zip |
2007-06-01 Benjamin Kosnik <bkoz@redhat.com>
* include/ext/throw_allocator.h (__throw_allocator::allocate):
Throw bad_alloc for out of memory conditions.
* testsuite/ext/throw_allocator/deallocate_global.cc: New.
* testsuite/ext/throw_allocator/check_delete.cc: Same.
* testsuite/ext/throw_allocator/check_allocate_max_size.cc: Same.
* testsuite/ext/throw_allocator/check_deallocate_null.cc: Same.
* testsuite/ext/throw_allocator/explicit_instantiation.cc: Same.
* testsuite/ext/throw_allocator/check_new.cc: Same.
* testsuite/ext/throw_allocator/deallocate_local.cc: Same.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@125261 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include')
-rw-r--r-- | libstdc++-v3/include/ext/throw_allocator.h | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/libstdc++-v3/include/ext/throw_allocator.h b/libstdc++-v3/include/ext/throw_allocator.h index bb2707d376f..240a3ccbe4f 100644 --- a/libstdc++-v3/include/ext/throw_allocator.h +++ b/libstdc++-v3/include/ext/throw_allocator.h @@ -210,32 +210,35 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) { return std::allocator<value_type>().max_size(); } pointer - allocate(size_type num, std::allocator<void>::const_pointer hint = 0) + allocate(size_type __n, std::allocator<void>::const_pointer hint = 0) { + if (__builtin_expect(__n > this->max_size(), false)) + std::__throw_bad_alloc(); + throw_conditionally(); - value_type* const a = std::allocator<value_type>().allocate(num, hint); - insert(a, sizeof(value_type) * num); + value_type* const a = std::allocator<value_type>().allocate(__n, hint); + insert(a, sizeof(value_type) * __n); return a; } void - construct(pointer p, const T& val) - { return std::allocator<value_type>().construct(p, val); } + construct(pointer __p, const T& val) + { return std::allocator<value_type>().construct(__p, val); } void - destroy(pointer p) - { std::allocator<value_type>().destroy(p); } + destroy(pointer __p) + { std::allocator<value_type>().destroy(__p); } void - deallocate(pointer p, size_type num) + deallocate(pointer __p, size_type __n) { - erase(p, sizeof(value_type) * num); - std::allocator<value_type>().deallocate(p, num); + erase(__p, sizeof(value_type) * __n); + std::allocator<value_type>().deallocate(__p, __n); } void - check_allocated(pointer p, size_type num) - { throw_allocator_base::check_allocated(p, sizeof(value_type) * num); } + check_allocated(pointer __p, size_type __n) + { throw_allocator_base::check_allocated(__p, sizeof(value_type) * __n); } void check_allocated(size_type label) |