• R/O
  • SSH
  • HTTPS

eirrepo: Commit


Commit MetaInfo

Revision206 (tree)
Time2019-04-02 19:23:48
Authorquiret

Log Message

- improved default alignment guarrantees for NativeHeapAllocator (now std::max_align_t)

Change Summary

Incremental Difference

--- common/sdk/OSUtils.memheap.h (revision 205)
+++ common/sdk/OSUtils.memheap.h (revision 206)
@@ -18,6 +18,9 @@
1818 #include "rwlist.hpp"
1919 #include "AVLTree.h"
2020
21+// For std::max_align_t.
22+#include <cstddef>
23+
2124 // Helper.
2225 template <typename numberType>
2326 AINLINE numberType UINT_DOWNPUSH( numberType value, numberType alignment )
@@ -38,6 +41,7 @@
3841 // can even design the features that your memory allocator should have ;)
3942
4043 static constexpr size_t MIN_PAGES_FOR_ISLAND = 4; // minimum amount of pages to reserve for an island.
44+ static constexpr size_t DEFAULT_ALIGNMENT = sizeof(std::max_align_t);
4145
4246 inline NativeHeapAllocator( void )
4347 {
@@ -90,7 +94,7 @@
9094 if ( alignedBy == 0 )
9195 {
9296 // I guess the user wants the best-default.
93- alignedBy = sizeof(void*);
97+ alignedBy = DEFAULT_ALIGNMENT;
9498 }
9599
96100 // If the allocation succeeded we have this data.
@@ -326,7 +330,7 @@
326330 }
327331
328332 // Simple realloc helper just because it is being exposed in the CRT aswell.
329- inline void* Realloc( void *memPtr, size_t newSize, size_t alignment = sizeof(void*) )
333+ inline void* Realloc( void *memPtr, size_t newSize, size_t alignment = DEFAULT_ALIGNMENT )
330334 {
331335 if ( memPtr == nullptr )
332336 {
Show on old repository browser