diff --git a/include/WinStd/Common.h b/include/WinStd/Common.h index aa7eac67..a4f23f45 100644 --- a/include/WinStd/Common.h +++ b/include/WinStd/Common.h @@ -792,20 +792,10 @@ namespace winstd /// Use for security sensitive data memory storage only. /// template - class sanitizing_allocator : public std::_Allocator_base<_Ty> + class sanitizing_allocator : public std::allocator<_Ty> { public: - typedef std::_Allocator_base<_Ty> _Mybase; - typedef typename _Mybase::value_type value_type; - - typedef value_type _FARQ *pointer; - typedef value_type _FARQ& reference; - typedef const value_type _FARQ *const_pointer; - typedef const value_type _FARQ& const_reference; - - typedef _SIZT size_type; - typedef _PDFT difference_type; - + typedef std::allocator<_Ty> _Mybase; /// /// Convert this type to sanitizing_allocator<_Other> @@ -817,28 +807,10 @@ namespace winstd }; - /// - /// Return address of mutable _Val - /// - inline pointer address(_In_ reference _Val) const - { - return ((pointer) &(char&)_Val); - } - - - /// - /// Return address of nonmutable _Val - /// - inline const_pointer address(_In_ const_reference _Val) const - { - return ((const_pointer) &(char&)_Val); - } - - /// /// Construct default allocator /// - inline sanitizing_allocator() + inline sanitizing_allocator() : _Mybase() { } @@ -846,26 +818,17 @@ namespace winstd /// /// Construct by copying /// - inline sanitizing_allocator(_In_ const sanitizing_allocator<_Ty>&) + inline sanitizing_allocator(_In_ const sanitizing_allocator<_Ty> &_Othr) : _Mybase(_Othr) { } /// /// Construct from a related allocator - template - inline sanitizing_allocator(_In_ const sanitizing_allocator<_Other>&) - { - } - - - /// - /// Assign from a related allocator /// template - inline sanitizing_allocator<_Ty>& operator=(_In_ const sanitizing_allocator<_Other>&) + inline sanitizing_allocator(_In_ const sanitizing_allocator<_Other> &_Othr) : _Mybase(_Othr) { - return (*this); } @@ -876,80 +839,7 @@ namespace winstd { // Sanitize then free. SecureZeroMemory(_Ptr, _Size); - ::operator delete(_Ptr); - } - - - /// - /// Allocate array of _Count elements - /// - inline pointer allocate(_In_ size_type _Count) - { - void *_Ptr = 0; - - if (_Count <= 0) - _Count = 0; - else if (((_SIZT)(-1)/sizeof(_Ty) < _Count) || (_Ptr = ::operator new(_Count * sizeof(_Ty))) == 0) - _THROW_NCEE(bad_alloc, 0); - - return ((_Ty _FARQ *)_Ptr); - } - - - /// - /// Allocate array of _Count elements - /// - inline pointer allocate(_In_ size_type _Count, _In_ const void _FARQ *) - { - return (allocate(_Count)); - } - - - /// - /// Construct object at _Ptr with value _Val - /// - inline void construct(_In_ pointer _Ptr, _In_ const _Ty& _Val) - { - void _FARQ *_Vptr = _Ptr; - ::new (_Vptr)_Ty1(_STD forward<_Ty2>(_Val)); - } - - - /// - /// Construct object at _Ptr with value _Val - /// - inline void construct(_In_ pointer _Ptr, _In_ _Ty&& _Val) - { - ::new ((void _FARQ *)_Ptr) _Ty(_STD forward<_Ty>(_Val)); - } - - - /// - /// Construct object at _Ptr with value _Val - /// - template - inline void construct(_In_ pointer _Ptr, _In_ _Other&& _Val) - { - ::new ((void _FARQ *)_Ptr) _Ty(_STD forward<_Other>(_Val)); - } - - - /// - /// Destroy object at _Ptr - /// - inline void destroy(_In_ pointer _Ptr) - { - _Ptr->~_Ty(); - } - - - /// - /// Estimate maximum array size - /// - inline _SIZT max_size() const - { - _SIZT _Count = (_SIZT)(-1) / sizeof (_Ty); - return (0 < _Count ? _Count : 1); + _Mybase::deallocate(_Ptr, _Size); } };