diff options
author | Paolo Carlini <pcarlini@suse.de> | 2004-10-15 10:54:57 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2004-10-15 10:54:57 +0000 |
commit | 0d6b41f2ddb7d0fc04a43f505598ba94a55fa4ee (patch) | |
tree | 73e97e39264f0d50f4b69d5007c1a70b6717fd2b | |
parent | 31246b8f0d515137f28162a8e856b5b9faff6339 (diff) | |
download | gcc-0d6b41f2ddb7d0fc04a43f505598ba94a55fa4ee.zip gcc-0d6b41f2ddb7d0fc04a43f505598ba94a55fa4ee.tar.gz gcc-0d6b41f2ddb7d0fc04a43f505598ba94a55fa4ee.tar.bz2 |
bitmap_allocator.h: Qualify ::operator delete.
2004-10-15 Paolo Carlini <pcarlini@suse.de>
* include/ext/bitmap_allocator.h: Qualify ::operator delete.
* src/bitmap_allocator.cc: Likewise.
* src/mt_allocator.cc: Use ::operator delete, not delete,
consistently with ::operator new.
* include/ext/bitmap_allocator.h (deallocate): Check for null
pointer.
* testsuite/ext/bitmap_allocator/check_deallocate_null.cc: New.
* testsuite/testsuite_allocator.h (check_deallocate_null): Add test.
From-SVN: r89089
-rw-r--r-- | libstdc++-v3/ChangeLog | 12 | ||||
-rw-r--r-- | libstdc++-v3/include/ext/bitmap_allocator.h | 15 | ||||
-rw-r--r-- | libstdc++-v3/src/bitmap_allocator.cc | 2 | ||||
-rw-r--r-- | libstdc++-v3/src/mt_allocator.cc | 20 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/ext/bitmap_allocator/check_deallocate_null.cc | 31 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/testsuite_allocator.h | 1 |
6 files changed, 64 insertions, 17 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index d5bdab5..7819e9e 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,15 @@ +2004-10-15 Paolo Carlini <pcarlini@suse.de> + + * include/ext/bitmap_allocator.h: Qualify ::operator delete. + * src/bitmap_allocator.cc: Likewise. + * src/mt_allocator.cc: Use ::operator delete, not delete, + consistently with ::operator new. + + * include/ext/bitmap_allocator.h (deallocate): Check for null + pointer. + * testsuite/ext/bitmap_allocator/check_deallocate_null.cc: New. + * testsuite/testsuite_allocator.h (check_deallocate_null): Add test. + 2004-10-14 Benjamin Kosnik <bkoz@redhat.com> * include/ext/mt_allocator.h (__mt_alloc::deallocate): Check for diff --git a/libstdc++-v3/include/ext/bitmap_allocator.h b/libstdc++-v3/include/ext/bitmap_allocator.h index dfb7cba..2328e14 100644 --- a/libstdc++-v3/include/ext/bitmap_allocator.h +++ b/libstdc++-v3/include/ext/bitmap_allocator.h @@ -674,14 +674,14 @@ namespace __gnu_cxx // Ok, the new block is greater than or equal to the // last block in the list of free blocks. We just free // the new block. - operator delete(static_cast<void*>(__addr)); + ::operator delete(static_cast<void*>(__addr)); return; } else { // Deallocate the last block in the list of free lists, // and insert the new one in it's correct position. - operator delete(static_cast<void*>(_S_free_list.back())); + ::operator delete(static_cast<void*>(_S_free_list.back())); _S_free_list.pop_back(); } } @@ -1095,10 +1095,13 @@ namespace __gnu_cxx void deallocate(pointer __p, size_type __n) throw() { - if (__builtin_expect(__n == 1, true)) - this->_M_deallocate_single_object(__p); - else - ::operator delete(__p); + if (__builtin_expect(__p != 0, true)) + { + if (__builtin_expect(__n == 1, true)) + this->_M_deallocate_single_object(__p); + else + ::operator delete(__p); + } } pointer diff --git a/libstdc++-v3/src/bitmap_allocator.cc b/libstdc++-v3/src/bitmap_allocator.cc index f37c5dc..3cd0fb9 100644 --- a/libstdc++-v3/src/bitmap_allocator.cc +++ b/libstdc++-v3/src/bitmap_allocator.cc @@ -121,7 +121,7 @@ namespace __gnu_cxx iterator __iter = _S_free_list.begin(); while (__iter != _S_free_list.end()) { - operator delete((void*)*__iter); + ::operator delete((void*)*__iter); ++__iter; } _S_free_list.clear(); diff --git a/libstdc++-v3/src/mt_allocator.cc b/libstdc++-v3/src/mt_allocator.cc index 7dff273..08f5c87 100644 --- a/libstdc++-v3/src/mt_allocator.cc +++ b/libstdc++-v3/src/mt_allocator.cc @@ -61,10 +61,10 @@ namespace __gnu_cxx delete __bin._M_address; __bin._M_address = __tmp; } - delete __bin._M_first; + ::operator delete(__bin._M_first); } - delete _M_bin; - delete _M_binmap; + ::operator delete(_M_bin); + ::operator delete(_M_binmap); } } @@ -190,10 +190,10 @@ namespace __gnu_cxx delete __bin._M_address; __bin._M_address = __tmp; } - delete __bin._M_first; - delete __bin._M_free; - delete __bin._M_used; - delete __bin._M_mutex; + ::operator delete(__bin._M_first); + ::operator delete(__bin._M_free); + ::operator delete(__bin._M_used); + ::operator delete(__bin._M_mutex); } ::operator delete(_M_thread_freelist_initial); } @@ -209,11 +209,11 @@ namespace __gnu_cxx delete __bin._M_address; __bin._M_address = __tmp; } - delete __bin._M_first; + ::operator delete(__bin._M_first); } } - delete _M_bin; - delete _M_binmap; + ::operator delete(_M_bin); + ::operator delete(_M_binmap); } } diff --git a/libstdc++-v3/testsuite/ext/bitmap_allocator/check_deallocate_null.cc b/libstdc++-v3/testsuite/ext/bitmap_allocator/check_deallocate_null.cc new file mode 100644 index 0000000..ebe8114 --- /dev/null +++ b/libstdc++-v3/testsuite/ext/bitmap_allocator/check_deallocate_null.cc @@ -0,0 +1,31 @@ +// +// Copyright (C) 2004 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 20.4.1.1 allocator members + +#include <ext/bitmap_allocator.h> +#include <testsuite_allocator.h> + +int main() +{ + typedef int value_type; + typedef __gnu_cxx::bitmap_allocator<value_type> allocator_type; + __gnu_test::check_deallocate_null<allocator_type>(); + return 0; +} diff --git a/libstdc++-v3/testsuite/testsuite_allocator.h b/libstdc++-v3/testsuite/testsuite_allocator.h index ecb210e..c10be53 100644 --- a/libstdc++-v3/testsuite/testsuite_allocator.h +++ b/libstdc++-v3/testsuite/testsuite_allocator.h @@ -202,6 +202,7 @@ namespace __gnu_test { // Let's not core here... Alloc a; + a.deallocate(NULL, 1); a.deallocate(NULL, 10); } }; // namespace __gnu_test |