//
// Don't eat heavily before inspecting this code.
//
+#define __STDC_WANT_LIB_EXT1__ 1
+#include <string.h>
+
#include <security_utilities/alloc.h>
#include <security_utilities/memutils.h>
#include <security_utilities/globalizer.h>
#include <stdlib.h>
#include <errno.h>
-using LowLevelMemoryUtilities::alignof;
+using LowLevelMemoryUtilities::alignof_template;
using LowLevelMemoryUtilities::increment;
using LowLevelMemoryUtilities::alignUp;
void SensitiveAllocator::free(void *addr) throw()
{
- memset(addr, 0, malloc_size(addr));
+ size_t size = malloc_size(addr);
+ ::memset_s(addr, size, 0, size);
DefaultAllocator::free(addr);
}
{
size_t oldSize = malloc_size(addr);
if (newSize < oldSize)
- memset(increment(addr, newSize), 0, oldSize - newSize);
+ ::memset_s(increment(addr, newSize), oldSize - newSize, 0, oldSize - newSize);
return DefaultAllocator::realloc(addr, newSize);
}
{
if (alloc == NULL)
alloc = &Allocator::standard();
- size = alignUp(size, alignof<Allocator *>());
+ size = alignUp(size, alignof_template<Allocator *>());
size_t totalSize = size + sizeof(Allocator *);
void *addr = alloc->malloc(totalSize);
*(Allocator **)increment(addr, size) = alloc;
void CssmHeap::operator delete (void *addr, size_t size) throw()
{
- void *end = increment(addr, alignUp(size, alignof<Allocator *>()));
+ void *end = increment(addr, alignUp(size, alignof_template<Allocator *>()));
(*(Allocator **)end)->free(addr);
}