/* * Copyright (c) 2011-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once #include #include #include namespace Swift { SWIFTEN_API void secureZeroMemory(char* memory, size_t numberOfBytes); template class SWIFTEN_API SafeAllocator : public std::allocator { public: template struct rebind { typedef SafeAllocator other; }; SafeAllocator() SWIFTEN_NOEXCEPT {} SafeAllocator(const SafeAllocator&) SWIFTEN_NOEXCEPT : std::allocator() {} template SafeAllocator(const SafeAllocator&) SWIFTEN_NOEXCEPT {} ~SafeAllocator() SWIFTEN_NOEXCEPT {} void deallocate (T* p, size_t num) { secureZeroMemory(reinterpret_cast(p), num); std::allocator::deallocate(p, num); } SWIFTEN_DEFAULT_COPY_ASSIGMNENT_OPERATOR(SafeAllocator) }; }