forked from qt-creator/qt-creator
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:
@@ -37,34 +37,24 @@ namespace Memory {
|
|||||||
|
|
||||||
inline char *allocate(std::size_t size)
|
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));
|
return static_cast<char*>(std::malloc(size));
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void deallocate(char *memory)
|
inline void deallocate(char *memory)
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_WIN32
|
|
||||||
_aligned_free(memory);
|
|
||||||
#else
|
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#if defined(__GNUC__) && !defined(__clang__)
|
#if defined(__GNUC__) && !defined(__clang__)
|
||||||
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wfree-nonheap-object"
|
#pragma GCC diagnostic ignored "-Wfree-nonheap-object"
|
||||||
#endif
|
#endif
|
||||||
std::free(memory);
|
std::free(memory);
|
||||||
|
#if defined(__GNUC__) && !defined(__clang__)
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline char *reallocate(char *oldMemory, std::size_t newSize)
|
inline char *reallocate(char *oldMemory, std::size_t newSize)
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_WIN32
|
return static_cast<char *>(std::realloc(oldMemory, newSize));
|
||||||
return static_cast<char*>(_aligned_realloc(oldMemory, newSize, 64));
|
|
||||||
#else
|
|
||||||
return static_cast<char*>(std::realloc(oldMemory, newSize));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Memory
|
} // namespace Memory
|
||||||
|
Reference in New Issue
Block a user