ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

_alloc.h
Go to the documentation of this file.
00001 /*
00002  *
00003  * Copyright (c) 1996,1997
00004  * Silicon Graphics Computer Systems, Inc.
00005  *
00006  * Copyright (c) 1997
00007  * Moscow Center for SPARC Technology
00008  *
00009  * Copyright (c) 1999
00010  * Boris Fomitchev
00011  *
00012  * This material is provided "as is", with absolutely no warranty expressed
00013  * or implied. Any use is at your own risk.
00014  *
00015  * Permission to use or copy this software for any purpose is hereby granted
00016  * without fee, provided the above notices are retained on all copies.
00017  * Permission to modify the code and to distribute modified code is granted,
00018  * provided the above notices are retained, and a notice that the code was
00019  * modified is included with the above copyright notice.
00020  *
00021  */
00022 
00023 /* NOTE: This is an internal header file, included by other STL headers.
00024  *   You should not attempt to use it directly.
00025  */
00026 
00027 #ifndef _STLP_INTERNAL_ALLOC_H
00028 #define _STLP_INTERNAL_ALLOC_H
00029 
00030 #ifndef _STLP_INTERNAL_CSTDDEF
00031 #  include <stl/_cstddef.h>
00032 #endif
00033 
00034 #ifndef _STLP_INTERNAL_CSTDLIB
00035 #  include <stl/_cstdlib.h>
00036 #endif
00037 
00038 #ifndef _STLP_INTERNAL_CSTRING
00039 #  include <stl/_cstring.h>
00040 #endif
00041 
00042 #ifndef _STLP_INTERNAL_ALGOBASE_H
00043 #  include <stl/_algobase.h>
00044 #endif
00045 
00046 #ifndef _STLP_INTERNAL_NEW_HEADER
00047 #  include <stl/_new.h>
00048 #endif
00049 
00050 #ifndef _STLP_INTERNAL_CONSTRUCT_H
00051 #  include <stl/_construct.h>
00052 #endif
00053 
00054 _STLP_BEGIN_NAMESPACE
00055 
00056 // Malloc-based allocator.  Typically slower than default alloc below.
00057 // Typically thread-safe and more storage efficient.
00058 
00059 #if !defined (_STLP_USE_NO_IOSTREAMS)
00060 typedef void (* __oom_handler_type)();
00061 #endif
00062 
00063 class _STLP_CLASS_DECLSPEC __malloc_alloc {
00064 public:
00065   // this one is needed for proper simple_alloc wrapping
00066   typedef char value_type;
00067   static void* _STLP_CALL allocate(size_t __n)
00068 #if !defined (_STLP_USE_NO_IOSTREAMS)
00069   ;
00070 #else
00071   {
00072     void *__result = malloc(__n);
00073     if (__result == 0) {
00074       _STLP_THROW_BAD_ALLOC;
00075     }
00076     return __result;
00077   }
00078 #endif
00079 
00080   static void _STLP_CALL deallocate(void* __p, size_t /* __n */) { free((char*)__p); }
00081 #if !defined (_STLP_USE_NO_IOSTREAMS)
00082   static __oom_handler_type _STLP_CALL set_malloc_handler(__oom_handler_type __f);
00083 #endif
00084 };
00085 
00086 // New-based allocator.  Typically slower than default alloc below.
00087 // Typically thread-safe and more storage efficient.
00088 class _STLP_CLASS_DECLSPEC __new_alloc {
00089 public:
00090   // this one is needed for proper simple_alloc wrapping
00091   typedef char value_type;
00092   static void* _STLP_CALL allocate(size_t __n) { return __stl_new(__n); }
00093   static void _STLP_CALL deallocate(void* __p, size_t) { __stl_delete(__p); }
00094 };
00095 
00096 // Allocator adaptor to check size arguments for debugging.
00097 // Reports errors using assert.  Checking can be disabled with
00098 // NDEBUG, but it's far better to just use the underlying allocator
00099 // instead when no checking is desired.
00100 // There is some evidence that this can confuse Purify.
00101 // This adaptor can only be applied to raw allocators
00102 
00103 template <class _Alloc>
00104 class __debug_alloc : public _Alloc {
00105 public:
00106   typedef _Alloc __allocator_type;
00107   typedef typename _Alloc::value_type value_type;
00108 private:
00109   struct __alloc_header {
00110     size_t __magic: 16;
00111     size_t __type_size:16;
00112     _STLP_UINT32_T _M_size;
00113   }; // that is 8 bytes for sure
00114   // Sunpro CC has bug on enums, so extra_before/after set explicitly
00115   enum { __pad = 8, __magic = 0xdeba, __deleted_magic = 0xdebd,
00116          __shred_byte = _STLP_SHRED_BYTE };
00117 
00118   enum { __extra_before = 16, __extra_after = 8 };
00119   // Size of space used to store size.  Note
00120   // that this must be large enough to preserve
00121   // alignment.
00122   static size_t _STLP_CALL __extra_before_chunk() {
00123     return (long)__extra_before / sizeof(value_type) +
00124       (size_t)((long)__extra_before % sizeof(value_type) > 0);
00125   }
00126   static size_t _STLP_CALL __extra_after_chunk() {
00127     return (long)__extra_after / sizeof(value_type) +
00128       (size_t)((long)__extra_after % sizeof(value_type) > 0);
00129   }
00130 public:
00131   __debug_alloc() {}
00132   ~__debug_alloc() {}
00133   static void* _STLP_CALL allocate(size_t);
00134   static void _STLP_CALL deallocate(void *, size_t);
00135 };
00136 
00137 #  if defined (__OS400__)
00138 // dums 02/05/2007: is it really necessary ?
00139 enum { _MAX_BYTES = 256 };
00140 #  else
00141 enum { _MAX_BYTES = 32 * sizeof(void*) };
00142 #  endif
00143 
00144 #if !defined (_STLP_USE_NO_IOSTREAMS)
00145 // Default node allocator.
00146 // With a reasonable compiler, this should be roughly as fast as the
00147 // original STL class-specific allocators, but with less fragmentation.
00148 class _STLP_CLASS_DECLSPEC __node_alloc {
00149   static void * _STLP_CALL _M_allocate(size_t& __n);
00150   /* __p may not be 0 */
00151   static void _STLP_CALL _M_deallocate(void *__p, size_t __n);
00152 
00153 public:
00154   // this one is needed for proper simple_alloc wrapping
00155   typedef char value_type;
00156   /* __n must be > 0      */
00157   static void* _STLP_CALL allocate(size_t& __n)
00158   { return (__n > (size_t)_MAX_BYTES) ? __stl_new(__n) : _M_allocate(__n); }
00159   /* __p may not be 0 */
00160   static void _STLP_CALL deallocate(void *__p, size_t __n)
00161   { if (__n > (size_t)_MAX_BYTES) __stl_delete(__p); else _M_deallocate(__p, __n); }
00162 };
00163 
00164 #  if defined (_STLP_USE_TEMPLATE_EXPORT)
00165 _STLP_EXPORT_TEMPLATE_CLASS __debug_alloc<__node_alloc>;
00166 #  endif
00167 
00168 #endif
00169 
00170 #if defined (_STLP_USE_TEMPLATE_EXPORT)
00171 _STLP_EXPORT_TEMPLATE_CLASS __debug_alloc<__new_alloc>;
00172 _STLP_EXPORT_TEMPLATE_CLASS __debug_alloc<__malloc_alloc>;
00173 #endif
00174 
00175 /* macro to convert the allocator for initialization
00176  * not using MEMBER_TEMPLATE_CLASSES as it should work given template constructor  */
00177 #if defined (_STLP_MEMBER_TEMPLATES) || ! defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
00178 /* if _STLP_NO_TEMPLATE_CONVERSIONS is set, the member template constructor is
00179  * not used implicitly to convert allocator parameter, so let us do it explicitly */
00180 #  if defined (_STLP_MEMBER_TEMPLATE_CLASSES) && defined (_STLP_NO_TEMPLATE_CONVERSIONS)
00181 #    define _STLP_CONVERT_ALLOCATOR(__a, _Tp) __stl_alloc_create(__a,(_Tp*)0)
00182 #  else
00183 #    define _STLP_CONVERT_ALLOCATOR(__a, _Tp) __a
00184 #  endif
00185 /* else convert, but only if partial specialization works, since else
00186  * Container::allocator_type won't be different */
00187 #else
00188 #  define _STLP_CONVERT_ALLOCATOR(__a, _Tp) __stl_alloc_create(__a,(_Tp*)0)
00189 #endif
00190 
00191 // Another allocator adaptor: _Alloc_traits.  This serves two
00192 // purposes.  First, make it possible to write containers that can use
00193 // either SGI-style allocators or standard-conforming allocator.
00194 
00195 // The fully general version.
00196 template <class _Tp, class _Allocator>
00197 struct _Alloc_traits {
00198   typedef _Allocator _Orig;
00199 #if !defined (_STLP_DONT_SUPPORT_REBIND_MEMBER_TEMPLATE)
00200   typedef typename _Allocator::_STLP_TEMPLATE rebind<_Tp> _Rebind_type;
00201   typedef typename _Rebind_type::other  allocator_type;
00202   static allocator_type create_allocator(const _Orig& __a)
00203   { return allocator_type(_STLP_CONVERT_ALLOCATOR(__a, _Tp)); }
00204 #else
00205   // this is not actually true, used only to pass this type through
00206   // to dynamic overload selection in _STLP_alloc_proxy methods
00207   typedef _Allocator allocator_type;
00208 #endif
00209 };
00210 
00211 #if defined (_STLP_USE_PERTHREAD_ALLOC)
00212 
00213 _STLP_END_NAMESPACE
00214 // include additional header here
00215 #  include <stl/_pthread_alloc.h>
00216 _STLP_BEGIN_NAMESPACE
00217 
00218 typedef __pthread_alloc __alloc_type;
00219 #elif defined (_STLP_USE_NEWALLOC)
00220 typedef __new_alloc __alloc_type;
00221 #elif defined (_STLP_USE_MALLOC)
00222 typedef __malloc_alloc __alloc_type;
00223 #else
00224 typedef __node_alloc __alloc_type;
00225 #endif
00226 
00227 #if defined (_STLP_DEBUG_ALLOC)
00228 typedef __debug_alloc<__alloc_type> __sgi_alloc;
00229 #else
00230 typedef __alloc_type __sgi_alloc;
00231 #endif
00232 
00233 #if !defined (_STLP_NO_ANACHRONISMS)
00234 typedef __sgi_alloc __single_client_alloc;
00235 typedef __sgi_alloc __multithreaded_alloc;
00236 #endif
00237 
00238 // This implements allocators as specified in the C++ standard.
00239 //
00240 // Note that standard-conforming allocators use many language features
00241 // that are not yet widely implemented.  In particular, they rely on
00242 // member templates, partial specialization, partial ordering of function
00243 // templates, the typename keyword, and the use of the template keyword
00244 // to refer to a template member of a dependent type.
00245 
00246 /*
00247 template <class _Tp>
00248 struct _AllocatorAux {
00249   typedef _Tp*       pointer;
00250   typedef const _Tp* const_pointer;
00251   typedef _Tp&       reference;
00252   typedef const _Tp& const_reference;
00253 
00254   pointer address(reference __x) const {return &__x;}
00255   const_pointer address(const_reference __x) const { return &__x; }
00256 };
00257 
00258 template <class _Tp>
00259 struct _AllocatorAux<const _Tp> {
00260   typedef _Tp*       pointer;
00261   typedef const _Tp* const_pointer;
00262   typedef _Tp&       reference;
00263   typedef const _Tp& const_reference;
00264 
00265   const_pointer address(const_reference __x) const { return &__x; }
00266 };
00267 */
00268 
00269 template <class _Tp>
00270 class allocator //: public _AllocatorAux<_Tp>
00271 /* A small helper struct to recognize STLport allocator implementation
00272  * from any user specialization one.
00273  */
00274                 : public __stlport_class<allocator<_Tp> >
00275 {
00276 public:
00277   typedef _Tp        value_type;
00278   typedef _Tp*       pointer;
00279   typedef const _Tp* const_pointer;
00280   typedef _Tp&       reference;
00281   typedef const _Tp& const_reference;
00282   typedef size_t     size_type;
00283   typedef ptrdiff_t  difference_type;
00284 #if defined (_STLP_MEMBER_TEMPLATE_CLASSES)
00285   template <class _Tp1> struct rebind {
00286     typedef allocator<_Tp1> other;
00287   };
00288 #endif
00289   allocator() _STLP_NOTHROW {}
00290 #if defined (_STLP_MEMBER_TEMPLATES)
00291   template <class _Tp1> allocator(const allocator<_Tp1>&) _STLP_NOTHROW {}
00292 #endif
00293   allocator(const allocator<_Tp>&) _STLP_NOTHROW {}
00294 #if !defined (_STLP_NO_MOVE_SEMANTIC)
00295   allocator(__move_source<allocator<_Tp> > src) _STLP_NOTHROW {}
00296 #endif
00297   ~allocator() _STLP_NOTHROW {}
00298   pointer address(reference __x) const {return &__x;}
00299   const_pointer address(const_reference __x) const { return &__x; }
00300   // __n is permitted to be 0.  The C++ standard says nothing about what the return value is when __n == 0.
00301   _Tp* allocate(size_type __n, const void* = 0) {
00302     if (__n > max_size()) {
00303       _STLP_THROW_BAD_ALLOC;
00304     }
00305     if (__n != 0) {
00306       size_type __buf_size = __n * sizeof(value_type);
00307       _Tp* __ret = __REINTERPRET_CAST(_Tp*, __sgi_alloc::allocate(__buf_size));
00308 #if defined (_STLP_DEBUG_UNINITIALIZED) && !defined (_STLP_DEBUG_ALLOC)
00309       memset((char*)__ret, _STLP_SHRED_BYTE, __buf_size);
00310 #endif
00311       return __ret;
00312     }
00313 
00314     return 0;
00315   }
00316   // __p is permitted to be a null pointer, only if n==0.
00317   void deallocate(pointer __p, size_type __n) {
00318     _STLP_ASSERT( (__p == 0) == (__n == 0) )
00319     if (__p != 0) {
00320 #if defined (_STLP_DEBUG_UNINITIALIZED) && !defined (_STLP_DEBUG_ALLOC)
00321       memset((char*)__p, _STLP_SHRED_BYTE, __n * sizeof(value_type));
00322 #endif
00323       __sgi_alloc::deallocate((void*)__p, __n * sizeof(value_type));
00324     }
00325   }
00326 #if !defined (_STLP_NO_ANACHRONISMS)
00327   // backwards compatibility
00328   void deallocate(pointer __p) const {  if (__p != 0) __sgi_alloc::deallocate((void*)__p, sizeof(value_type)); }
00329 #endif
00330   size_type max_size() const _STLP_NOTHROW  { return size_t(-1) / sizeof(value_type); }
00331   void construct(pointer __p, const_reference __val) { _STLP_STD::_Copy_Construct(__p, __val); }
00332   void destroy(pointer __p) { _STLP_STD::_Destroy(__p); }
00333 
00334 #if defined (_STLP_NO_EXTENSIONS)
00335   /* STLport extension giving rounded size of an allocated memory buffer
00336    * This method do not have to be part of a user defined allocator implementation
00337    * and won't even be called if such a function was granted.
00338    */
00339 protected:
00340 #endif
00341   _Tp* _M_allocate(size_type __n, size_type& __allocated_n) {
00342     if (__n > max_size()) {
00343       _STLP_THROW_BAD_ALLOC;
00344     }
00345 
00346     if (__n != 0) {
00347       size_type __buf_size = __n * sizeof(value_type);
00348       _Tp* __ret = __REINTERPRET_CAST(_Tp*, __sgi_alloc::allocate(__buf_size));
00349 #if defined (_STLP_DEBUG_UNINITIALIZED) && !defined (_STLP_DEBUG_ALLOC)
00350       memset((char*)__ret, _STLP_SHRED_BYTE, __buf_size);
00351 #endif
00352       __allocated_n = __buf_size / sizeof(value_type);
00353       return __ret;
00354     }
00355 
00356     return 0;
00357   }
00358 #if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
00359   void _M_swap_workaround(allocator<_Tp>& __other) {}
00360 #endif
00361 };
00362 
00363 _STLP_TEMPLATE_NULL
00364 class _STLP_CLASS_DECLSPEC allocator<void> {
00365 public:
00366   typedef size_t      size_type;
00367   typedef ptrdiff_t   difference_type;
00368   typedef void*       pointer;
00369   typedef const void* const_pointer;
00370 #if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
00371   typedef void        value_type;
00372 #endif
00373 #if defined (_STLP_MEMBER_TEMPLATE_CLASSES)
00374   template <class _Tp1> struct rebind {
00375     typedef allocator<_Tp1> other;
00376   };
00377 #endif
00378 };
00379 
00380 template <class _T1, class _T2>
00381 inline bool _STLP_CALL operator==(const allocator<_T1>&, const allocator<_T2>&) _STLP_NOTHROW
00382 { return true; }
00383 template <class _T1, class _T2>
00384 inline bool _STLP_CALL operator!=(const allocator<_T1>&, const allocator<_T2>&) _STLP_NOTHROW
00385 { return false; }
00386 
00387 #if defined (_STLP_USE_TEMPLATE_EXPORT)
00388 _STLP_EXPORT_TEMPLATE_CLASS allocator<char>;
00389 #  if defined (_STLP_HAS_WCHAR_T)
00390 _STLP_EXPORT_TEMPLATE_CLASS allocator<wchar_t>;
00391 #  endif
00392 #  if defined (_STLP_USE_PTR_SPECIALIZATIONS)
00393 _STLP_EXPORT_TEMPLATE_CLASS allocator<void*>;
00394 #  endif
00395 #endif
00396 
00397 _STLP_MOVE_TO_PRIV_NAMESPACE
00398 
00399 template <class _Tp>
00400 struct __alloc_type_traits {
00401 #if !defined (__BORLANDC__)
00402   typedef typename _IsSTLportClass<allocator<_Tp> >::_Ret _STLportAlloc;
00403 #else
00404   enum { _Is = _IsSTLportClass<allocator<_Tp> >::_Is };
00405   typedef typename __bool2type<_Is>::_Ret _STLportAlloc;
00406 #endif
00407   //The default allocator implementation which is recognize thanks to the
00408   //__stlport_class inheritance is a stateless object so:
00409   typedef _STLportAlloc has_trivial_default_constructor;
00410   typedef _STLportAlloc has_trivial_copy_constructor;
00411   typedef _STLportAlloc has_trivial_assignment_operator;
00412   typedef _STLportAlloc has_trivial_destructor;
00413   typedef _STLportAlloc is_POD_type;
00414 };
00415 
00416 _STLP_MOVE_TO_STD_NAMESPACE
00417 
00418 #if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
00419 template <class _Tp>
00420 struct __type_traits<allocator<_Tp> > : _STLP_PRIV __alloc_type_traits<_Tp> {};
00421 #else
00422 _STLP_TEMPLATE_NULL
00423 struct __type_traits<allocator<char> > : _STLP_PRIV __alloc_type_traits<char> {};
00424 #  if defined (_STLP_HAS_WCHAR_T)
00425 _STLP_TEMPLATE_NULL
00426 struct __type_traits<allocator<wchar_t> > : _STLP_PRIV __alloc_type_traits<wchar_t> {};
00427 #  endif
00428 #  if defined (_STLP_USE_PTR_SPECIALIZATIONS)
00429 _STLP_TEMPLATE_NULL
00430 struct __type_traits<allocator<void*> > : _STLP_PRIV __alloc_type_traits<void*> {};
00431 #  endif
00432 #endif
00433 
00434 
00435 #if !defined (_STLP_FORCE_ALLOCATORS)
00436 #  define _STLP_FORCE_ALLOCATORS(a,y)
00437 #endif
00438 
00439 #if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_MEMBER_TEMPLATE_CLASSES)
00440 // The version for the default allocator, for rare occasion when we have partial spec w/o member template classes
00441 template <class _Tp, class _Tp1>
00442 struct _Alloc_traits<_Tp, allocator<_Tp1> > {
00443   typedef allocator<_Tp1> _Orig;
00444   typedef allocator<_Tp> allocator_type;
00445   static allocator_type create_allocator(const allocator<_Tp1 >& __a)
00446   { return allocator_type(_STLP_CONVERT_ALLOCATOR(__a, _Tp)); }
00447 };
00448 #endif
00449 
00450 #if !defined (_STLP_DONT_SUPPORT_REBIND_MEMBER_TEMPLATE) && defined (_STLP_MEMBER_TEMPLATES)
00451 template <class _Tp, class _Alloc>
00452 inline _STLP_TYPENAME_ON_RETURN_TYPE _Alloc_traits<_Tp, _Alloc>::allocator_type  _STLP_CALL
00453 __stl_alloc_create(const _Alloc& __a, const _Tp*) {
00454   typedef typename _Alloc::_STLP_TEMPLATE rebind<_Tp>::other _Rebound_type;
00455   return _Rebound_type(__a);
00456 }
00457 #else
00458 // If custom allocators are being used without member template classes support :
00459 // user (on purpose) is forced to define rebind/get operations !!!
00460 template <class _Tp1, class _Tp2>
00461 inline allocator<_Tp2>& _STLP_CALL
00462 __stl_alloc_rebind(allocator<_Tp1>& __a, const _Tp2*) {  return (allocator<_Tp2>&)(__a); }
00463 template <class _Tp1, class _Tp2>
00464 inline allocator<_Tp2> _STLP_CALL
00465 __stl_alloc_create(const allocator<_Tp1>&, const _Tp2*) { return allocator<_Tp2>(); }
00466 #endif
00467 
00468 _STLP_MOVE_TO_PRIV_NAMESPACE
00469 
00470 // inheritance is being used for EBO optimization
00471 template <class _Value, class _Tp, class _MaybeReboundAlloc>
00472 class _STLP_alloc_proxy : public _MaybeReboundAlloc {
00473 private:
00474   typedef _MaybeReboundAlloc _Base;
00475   typedef typename _Base::size_type size_type;
00476   typedef _STLP_alloc_proxy<_Value, _Tp, _MaybeReboundAlloc> _Self;
00477 public:
00478   _Value _M_data;
00479 
00480   _STLP_alloc_proxy (const _MaybeReboundAlloc& __a, _Value __p) :
00481     _MaybeReboundAlloc(__a), _M_data(__p) {}
00482 
00483 #if !defined (_STLP_NO_MOVE_SEMANTIC)
00484   _STLP_alloc_proxy (__move_source<_Self> src) :
00485     _Base(_STLP_PRIV _AsMoveSource(src.get()._M_base())),
00486     _M_data(_STLP_PRIV _AsMoveSource(src.get()._M_data)) {}
00487 
00488   _Base& _M_base()
00489   { return *this; }
00490 #endif
00491 
00492 private:
00493   /* Following are helper methods to detect stateless allocators and avoid
00494    * swap in this case. For some compilers (VC6) it is a workaround for a
00495    * compiler bug in the Empty Base class Optimization feature, for others
00496    * it is a small optimization or nothing if no EBO. */
00497   void _M_swap_alloc(_Self&, const __true_type& /*_IsStateless*/)
00498   {}
00499 
00500   void _M_swap_alloc(_Self& __x, const __false_type& /*_IsStateless*/) {
00501     _MaybeReboundAlloc &__base_this = *this;
00502     _MaybeReboundAlloc &__base_x = __x;
00503     _STLP_STD::swap(__base_this, __base_x);
00504   }
00505 
00506 public:
00507   void _M_swap_alloc(_Self& __x) {
00508 #if !defined (__BORLANDC__)
00509     typedef typename _IsStateless<_MaybeReboundAlloc>::_Ret _StatelessAlloc;
00510 #else
00511     typedef typename __bool2type<_IsStateless<_MaybeReboundAlloc>::_Is>::_Ret _StatelessAlloc;
00512 #endif
00513     _M_swap_alloc(__x, _StatelessAlloc());
00514   }
00515 
00516   /* We need to define the following swap implementation for allocator with state
00517    * as those allocators might have implement a special swap function to correctly
00518    * move datas from an instance to the oher, _STLP_alloc_proxy should not break
00519    * this mecanism. */
00520   void swap(_Self& __x) {
00521     _M_swap_alloc(__x);
00522     _STLP_STD::swap(_M_data, __x._M_data);
00523   }
00524 
00525   _Tp* allocate(size_type __n, size_type& __allocated_n) {
00526 #if !defined (__BORLANDC__)
00527     typedef typename _IsSTLportClass<_MaybeReboundAlloc>::_Ret _STLportAlloc;
00528 #else
00529     typedef typename __bool2type<_IsSTLportClass<_MaybeReboundAlloc>::_Is>::_Ret _STLportAlloc;
00530 #endif
00531     return allocate(__n, __allocated_n, _STLportAlloc());
00532   }
00533 
00534   // Unified interface to perform allocate()/deallocate() with limited
00535   // language support
00536 #if defined (_STLP_DONT_SUPPORT_REBIND_MEMBER_TEMPLATE)
00537   // else it is rebound already, and allocate() member is accessible
00538   _Tp* allocate(size_type __n)
00539   { return __stl_alloc_rebind(__STATIC_CAST(_Base&, *this), __STATIC_CAST(_Tp*, 0)).allocate(__n, 0); }
00540   void deallocate(_Tp* __p, size_type __n)
00541   { __stl_alloc_rebind(__STATIC_CAST(_Base&, *this), __STATIC_CAST(_Tp*, 0)).deallocate(__p, __n); }
00542 private:
00543   _Tp* allocate(size_type __n, size_type& __allocated_n, const __true_type& /*STLport allocator*/)
00544   { return __stl_alloc_rebind(__STATIC_CAST(_Base&, *this), __STATIC_CAST(_Tp*, 0))._M_allocate(__n, __allocated_n); }
00545 #else
00546   //Expose Standard allocate overload (using expression do not work for some compilers (Borland))
00547   _Tp* allocate(size_type __n)
00548   { return _Base::allocate(__n); }
00549 private:
00550   _Tp* allocate(size_type __n, size_type& __allocated_n, const __true_type& /*STLport allocator*/)
00551   { return _Base::_M_allocate(__n, __allocated_n); }
00552 #endif
00553 
00554   _Tp* allocate(size_type __n, size_type& __allocated_n, const __false_type& /*STLport allocator*/)
00555   { __allocated_n = __n; return allocate(__n); }
00556 };
00557 
00558 #if defined (_STLP_USE_TEMPLATE_EXPORT)
00559 _STLP_EXPORT_TEMPLATE_CLASS _STLP_alloc_proxy<char*, char, allocator<char> >;
00560 #  if defined (_STLP_HAS_WCHAR_T)
00561 _STLP_EXPORT_TEMPLATE_CLASS _STLP_alloc_proxy<wchar_t*, wchar_t, allocator<wchar_t> >;
00562 #  endif
00563 #  if defined (_STLP_USE_PTR_SPECIALIZATIONS)
00564 _STLP_EXPORT_TEMPLATE_CLASS _STLP_alloc_proxy<void**, void*, allocator<void*> >;
00565 #  endif
00566 #endif
00567 
00568 _STLP_MOVE_TO_STD_NAMESPACE
00569 _STLP_END_NAMESPACE
00570 
00571 #if defined (_STLP_EXPOSE_GLOBALS_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION)
00572 #  include <stl/_alloc.c>
00573 #endif
00574 
00575 #endif /* _STLP_INTERNAL_ALLOC_H */
00576 
00577 // Local Variables:
00578 // mode:C++
00579 // End:
00580 

Generated on Sun May 27 2012 04:28:49 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.