bitmap_allocator.h: Qualify ::operator delete.
authorPaolo Carlini <pcarlini@suse.de>
Fri, 15 Oct 2004 10:54:57 +0000 (10:54 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Fri, 15 Oct 2004 10:54:57 +0000 (10:54 +0000)
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

libstdc++-v3/ChangeLog
libstdc++-v3/include/ext/bitmap_allocator.h
libstdc++-v3/src/bitmap_allocator.cc
libstdc++-v3/src/mt_allocator.cc
libstdc++-v3/testsuite/ext/bitmap_allocator/check_deallocate_null.cc [new file with mode: 0644]
libstdc++-v3/testsuite/testsuite_allocator.h

index d5bdab5..7819e9e 100644 (file)
@@ -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
index dfb7cba..2328e14 100644 (file)
@@ -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 
index f37c5dc..3cd0fb9 100644 (file)
@@ -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();
index 7dff273..08f5c87 100644 (file)
@@ -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 (file)
index 0000000..ebe8114
--- /dev/null
@@ -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;
+}
index ecb210e..c10be53 100644 (file)
@@ -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