Utils: Use unaligned malloc on windows too

We do not align the small string anymore.

Change-Id: I933f95ea14f90fff29cb8ab75d987039ea7f8a3e
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Marco Bubke
2020-05-24 10:51:35 +02:00
parent 0b3d03121f
commit 49dc889c7f

View File

@@ -37,34 +37,24 @@ namespace Memory {
inline char *allocate(std::size_t size)
{
#ifdef Q_OS_WIN32
return static_cast<char*>(_aligned_malloc(size, 64));
#else
return static_cast<char*>(std::malloc(size));
#endif
}
inline void deallocate(char *memory)
{
#ifdef Q_OS_WIN32
_aligned_free(memory);
#else
#pragma GCC diagnostic push
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wfree-nonheap-object"
#endif
std::free(memory);
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif
}
inline char *reallocate(char *oldMemory, std::size_t newSize)
{
#ifdef Q_OS_WIN32
return static_cast<char*>(_aligned_realloc(oldMemory, newSize, 64));
#else
return static_cast<char *>(std::realloc(oldMemory, newSize));
#endif
}
} // namespace Memory