/* * Copyright (c) 2011-2013 Remko Tronçon * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. */ #pragma once #include #include namespace Swift { void secureZeroMemory(char* memory, size_t numberOfBytes); template class SafeAllocator : public std::allocator { public: template struct rebind { typedef SafeAllocator other; }; SafeAllocator() throw() {} SafeAllocator(const SafeAllocator&) throw() : std::allocator() {} template SafeAllocator(const SafeAllocator&) throw() {} ~SafeAllocator() throw() {} void deallocate (T* p, size_t num) { secureZeroMemory(reinterpret_cast(p), num); std::allocator::deallocate(p, num); } private: }; }