3 * ***** BEGIN GPL LICENSE BLOCK *****
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software Foundation,
17 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 * Contributor(s): Peter Schlaile <peter@schlaile.de> 2005
21 * ***** END GPL LICENSE BLOCK *****
24 #ifndef __MEM_Allocator_h_included__
25 #define __MEM_Allocator_h_included__ 1
27 #include "guardedalloc/MEM_guardedalloc.h"
28 #include "guardedalloc/BLO_sys_types.h"
31 #if _MSC_VER < 1300 // 1200 == VC++ 6.0 according to boost
32 #define MS_VISUALC_6_0_WORKAROUND 1
36 template<typename _Tp>
39 typedef size_t size_type;
40 typedef ptrdiff_t difference_type;
42 typedef const _Tp* const_pointer;
43 typedef _Tp& reference;
44 typedef const _Tp& const_reference;
45 typedef _Tp value_type;
47 #ifndef MS_VISUALC_6_0_WORKAROUND
48 template<typename _Tp1>
50 typedef MEM_Allocator<_Tp1> other;
54 MEM_Allocator() throw() {}
55 MEM_Allocator(const MEM_Allocator&) throw() {}
57 #ifndef MS_VISUALC_6_0_WORKAROUND
58 template<typename _Tp1>
59 MEM_Allocator(const MEM_Allocator<_Tp1>) throw() { }
62 ~MEM_Allocator() throw() {}
64 pointer address(reference __x) const { return &__x; }
66 const_pointer address(const_reference __x) const { return &__x; }
68 #ifdef MS_VISUALC_6_0_WORKAROUND
69 char *_Charalloc(size_type n) {
70 return (char *) MEM_mallocN(n, "STL MEM_Allocator VC6.0");
73 // NB: __n is permitted to be 0. The C++ standard says nothing
74 // about what the return value is when __n == 0.
75 _Tp* allocate(size_type __n, const void* = 0) {
78 __ret = static_cast<_Tp*>(
79 MEM_mallocN(__n * sizeof(_Tp),
80 "STL MEM_Allocator"));
84 #ifndef MS_VISUALC_6_0_WORKAROUND
85 // __p is not permitted to be a null pointer.
86 void deallocate(pointer __p, size_type){
90 // __p is not permitted to be a null pointer.
91 void deallocate(void* __p, size_type){
96 size_type max_size() const throw() {
97 return size_t(-1) / sizeof(_Tp);
100 void construct(pointer __p, const _Tp& __val) {
104 void destroy(pointer __p) {