summaryrefslogtreecommitdiffstats
path: root/contrib/libstdc++/include/ext/debug_allocator.h
diff options
context:
space:
mode:
authorkan <kan@FreeBSD.org>2007-05-19 01:25:07 +0000
committerkan <kan@FreeBSD.org>2007-05-19 01:25:07 +0000
commit7865836f4b0f698454c31b4593effcb032c22c1e (patch)
treeea6c2718dc1e45ed535d194df808ef31f0ebac92 /contrib/libstdc++/include/ext/debug_allocator.h
parent1f9ea4d0a40cca64d60cf4dab152349da7b9dddf (diff)
downloadFreeBSD-src-7865836f4b0f698454c31b4593effcb032c22c1e.zip
FreeBSD-src-7865836f4b0f698454c31b4593effcb032c22c1e.tar.gz
GCC 4.2.0 release C++ standard library and runtime support code.
Diffstat (limited to 'contrib/libstdc++/include/ext/debug_allocator.h')
-rw-r--r--contrib/libstdc++/include/ext/debug_allocator.h35
1 files changed, 21 insertions, 14 deletions
diff --git a/contrib/libstdc++/include/ext/debug_allocator.h b/contrib/libstdc++/include/ext/debug_allocator.h
index 7ea6fb4..43a9a87 100644
--- a/contrib/libstdc++/include/ext/debug_allocator.h
+++ b/contrib/libstdc++/include/ext/debug_allocator.h
@@ -1,6 +1,6 @@
// Allocators -*- C++ -*-
-// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2002, 2003, 2004, 2005 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
@@ -15,7 +15,7 @@
// 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,
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// As a special exception, you may use this file as part of a free software
@@ -48,18 +48,18 @@
#ifndef _DEBUG_ALLOCATOR_H
#define _DEBUG_ALLOCATOR_H 1
-#include <cstdlib>
+#include <stdexcept>
+
+_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
+
+ using std::size_t;
-namespace __gnu_cxx
-{
/**
* @brief A meta-allocator with debugging bits, as per [20.4].
*
* This is precisely the allocator defined in the C++ Standard.
* - all allocation calls operator new
* - all deallocation calls operator delete
- *
- * (See @link Allocators allocators info @endlink for more.)
*/
template<typename _Alloc>
class debug_allocator
@@ -108,14 +108,21 @@ namespace __gnu_cxx
void
deallocate(pointer __p, size_type __n)
{
- if (!__p)
- abort();
- pointer __real_p = __p - _M_extra;
- if (*reinterpret_cast<size_type*>(__real_p) != __n)
- abort();
- _M_allocator.deallocate(__real_p, __n + _M_extra);
+ if (__p)
+ {
+ pointer __real_p = __p - _M_extra;
+ if (*reinterpret_cast<size_type*>(__real_p) != __n)
+ {
+ throw std::runtime_error("debug_allocator::deallocate"
+ " wrong size");
+ }
+ _M_allocator.deallocate(__real_p, __n + _M_extra);
+ }
+ else
+ throw std::runtime_error("debug_allocator::deallocate null pointer");
}
};
-} // namespace __gnu_cxx
+
+_GLIBCXX_END_NAMESPACE
#endif
OpenPOWER on IntegriCloud