diff options
author | Benjamin Kosnik <bkoz@redhat.com> | 2004-10-14 23:03:26 +0000 |
---|---|---|
committer | Benjamin Kosnik <bkoz@gcc.gnu.org> | 2004-10-14 23:03:26 +0000 |
commit | 5d1b2a1e421e770aba056e6b1405ed0eb29d29eb (patch) | |
tree | 76f340573e6c3e486eb792b698ac5d5058a12c6e /libstdc++-v3/include/ext/mt_allocator.h | |
parent | c4e18b1c3e26a9afeb3438f6173742ac5cb1fece (diff) | |
download | gcc-5d1b2a1e421e770aba056e6b1405ed0eb29d29eb.tar.gz |
mt_allocator.h (__mt_alloc::deallocate): Check for null pointer.
2004-10-14 Benjamin Kosnik <bkoz@redhat.com>
* include/ext/mt_allocator.h (__mt_alloc::deallocate): Check for
null pointer.
* include/ext/pool_allocator.h (debug_allocator::deallocate):
Check pointer value.
* include/ext/debug_allocator.h (debug_allocator::deallocate):
Throw exceptions, don't abort.
* include/ext/array_allocator.h
(array_allocator_base::deallocate): Remove unused parameters.
* testsuite/testsuite_allocator.h (check_deallocate_null): New.
* testsuite/ext/mt_allocator/check_deallocate_null.cc: New.
* testsuite/ext/mt_allocator/check_deallocate_null_thread.cc: New.
* testsuite/ext/array_allocator/check_deallocate_null.cc: New.
* testsuite/ext/debug_allocator/check_deallocate_null.cc: New.
* testsuite/ext/malloc_allocator/check_deallocate_null.cc: New.
* testsuite/ext/new_allocator/check_deallocate_null.cc: New.
* testsuite/ext/pool_allocator/check_deallocate_null.cc: New.
* testsuite/testsuite_allocator.h (check_new): Add instance argument.
* testsuite/ext/array_allocator/check_new.cc: New.
From-SVN: r89060
Diffstat (limited to 'libstdc++-v3/include/ext/mt_allocator.h')
-rw-r--r-- | libstdc++-v3/include/ext/mt_allocator.h | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/libstdc++-v3/include/ext/mt_allocator.h b/libstdc++-v3/include/ext/mt_allocator.h index 3bbfc79b4bb..d4d51d8a55e 100644 --- a/libstdc++-v3/include/ext/mt_allocator.h +++ b/libstdc++-v3/include/ext/mt_allocator.h @@ -724,14 +724,17 @@ namespace __gnu_cxx __mt_alloc<_Tp, _Poolp>:: deallocate(pointer __p, size_type __n) { - // Requests larger than _M_max_bytes are handled by operators - // new/delete directly. - __pool_type& __pool = this->_S_get_pool(); - const size_t __bytes = __n * sizeof(_Tp); - if (__pool._M_check_threshold(__bytes)) - ::operator delete(__p); - else - __pool._M_reclaim_block(reinterpret_cast<char*>(__p), __bytes); + if (__builtin_expect(__p != 0, true)) + { + // Requests larger than _M_max_bytes are handled by + // operators new/delete directly. + __pool_type& __pool = this->_S_get_pool(); + const size_t __bytes = __n * sizeof(_Tp); + if (__pool._M_check_threshold(__bytes)) + ::operator delete(__p); + else + __pool._M_reclaim_block(reinterpret_cast<char*>(__p), __bytes); + } } template<typename _Tp, typename _Poolp> |