43 #ifndef _DEBUG_ALLOCATOR_H
44 #define _DEBUG_ALLOCATOR_H 1
48 namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
50 _GLIBCXX_BEGIN_NAMESPACE_VERSION
62 template<
typename _Alloc>
66 typedef typename _Alloc::size_type size_type;
67 typedef typename _Alloc::difference_type difference_type;
68 typedef typename _Alloc::pointer pointer;
69 typedef typename _Alloc::const_pointer const_pointer;
70 typedef typename _Alloc::reference reference;
71 typedef typename _Alloc::const_reference const_reference;
72 typedef typename _Alloc::value_type value_type;
84 const size_t __obj_size =
sizeof(value_type);
85 _M_extra = (
sizeof(size_type) + __obj_size - 1) / __obj_size;
89 allocate(size_type __n)
91 pointer __res = _M_allocator.allocate(__n + _M_extra);
92 size_type* __ps =
reinterpret_cast<size_type*
>(__res);
94 return __res + _M_extra;
98 allocate(size_type __n,
const void* __hint)
100 pointer __res = _M_allocator.allocate(__n + _M_extra, __hint);
101 size_type* __ps =
reinterpret_cast<size_type*
>(__res);
103 return __res + _M_extra;
107 deallocate(pointer __p, size_type __n)
111 pointer __real_p = __p - _M_extra;
112 if (*reinterpret_cast<size_type*>(__real_p) != __n)
117 _M_allocator.deallocate(__real_p, __n + _M_extra);
124 _GLIBCXX_END_NAMESPACE_VERSION
A meta-allocator with debugging bits, as per [20.4].This is precisely the allocator defined in the C+...
One of two subclasses of exception.