/* * Copyright (c) 2011 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 { 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) { std::fill(reinterpret_cast(p), reinterpret_cast(p + num), 0); std::allocator::deallocate(p, num); } }; }