3 * ***** BEGIN GPL/BL DUAL 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. The Blender
9 * Foundation also sells licenses for use in proprietary software under
10 * the Blender License. See http://www.blender.org/BL/ for information
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 * Contributor(s): Peter Schlaile <peter@schlaile.de> 2005
24 * ***** END GPL/BL DUAL LICENSE BLOCK *****
27 #ifndef __MEM_Allocator_h_included__
28 #define __MEM_Allocator_h_included__ 1
30 #include "guardedalloc/MEM_guardedalloc.h"
33 #if _MSC_VER < 1300 // 1200 == VC++ 6.0 according to boost
34 #define MS_VISUALC_6_0_WORKAROUND 1
38 template<typename _Tp
>
41 typedef size_t size_type
;
42 typedef ptrdiff_t difference_type
;
44 typedef const _Tp
* const_pointer
;
45 typedef _Tp
& reference
;
46 typedef const _Tp
& const_reference
;
47 typedef _Tp value_type
;
49 #ifndef MS_VISUALC_6_0_WORKAROUND
50 template<typename _Tp1
>
52 typedef MEM_Allocator
<_Tp1
> other
;
56 MEM_Allocator() throw() {}
57 MEM_Allocator(const MEM_Allocator
&) throw() {}
59 #ifndef MS_VISUALC_6_0_WORKAROUND
60 template<typename _Tp1
>
61 MEM_Allocator(const MEM_Allocator
<_Tp1
>) throw() { }
64 ~MEM_Allocator() throw() {}
66 pointer
address(reference __x
) const { return &__x
; }
68 const_pointer
address(const_reference __x
) const { return &__x
; }
70 #ifdef MS_VISUALC_6_0_WORKAROUND
71 char *_Charalloc(size_type n
) {
72 return (char *) MEM_mallocN(n
, "STL MEM_Allocator VC6.0");
75 // NB: __n is permitted to be 0. The C++ standard says nothing
76 // about what the return value is when __n == 0.
77 _Tp
* allocate(size_type __n
, const void* = 0) {
80 __ret
= static_cast<_Tp
*>(
81 MEM_mallocN(__n
* sizeof(_Tp
),
82 "STL MEM_Allocator"));
86 #ifndef MS_VISUALC_6_0_WORKAROUND
87 // __p is not permitted to be a null pointer.
88 void deallocate(pointer __p
, size_type
){
92 // __p is not permitted to be a null pointer.
93 void deallocate(void* __p
, size_type
){
98 size_type
max_size() const throw() {
99 return size_t(-1) / sizeof(_Tp
);
102 void construct(pointer __p
, const _Tp
& __val
) {
106 void destroy(pointer __p
) {