From 0bbbb585d17347927b6aabb6a697704040f1c143 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Sat, 15 Jul 2017 14:32:29 -0700 Subject: [PATCH] Cleanup. --- examples/07-callback/callback.cpp | 8 +++++--- src/bgfx.cpp | 8 +++++--- src/renderer_vk.cpp | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/examples/07-callback/callback.cpp b/examples/07-callback/callback.cpp index c3a47b8dd..4517905c4 100644 --- a/examples/07-callback/callback.cpp +++ b/examples/07-callback/callback.cpp @@ -240,6 +240,8 @@ struct BgfxCallback : public bgfx::CallbackI AviWriter* m_writer; }; +const size_t kNaturalAlignment = 8; + class BgfxAllocator : public bx::AllocatorI { public: @@ -259,7 +261,7 @@ public: { if (NULL != _ptr) { - if (BX_CONFIG_ALLOCATOR_NATURAL_ALIGNMENT >= _align) + if (kNaturalAlignment >= _align) { bx::debugPrintf("%s(%d): FREE %p\n", _file, _line, _ptr); ::free(_ptr); @@ -275,7 +277,7 @@ public: } else if (NULL == _ptr) { - if (BX_CONFIG_ALLOCATOR_NATURAL_ALIGNMENT >= _align) + if (kNaturalAlignment >= _align) { void* ptr = ::malloc(_size); bx::debugPrintf("%s(%d): ALLOC %p of %d byte(s)\n", _file, _line, ptr, _size); @@ -287,7 +289,7 @@ public: return bx::alignedAlloc(this, _size, _align, _file, _line); } - if (BX_CONFIG_ALLOCATOR_NATURAL_ALIGNMENT >= _align) + if (kNaturalAlignment >= _align) { void* ptr = ::realloc(_ptr, _size); bx::debugPrintf("%s(%d): REALLOC %p (old %p) of %d byte(s)\n", _file, _line, ptr, _ptr, _size); diff --git a/src/bgfx.cpp b/src/bgfx.cpp index a50f5bccf..7fd7e7a47 100644 --- a/src/bgfx.cpp +++ b/src/bgfx.cpp @@ -148,6 +148,8 @@ namespace bgfx # define BGFX_CONFIG_MEMORY_TRACKING (BGFX_CONFIG_DEBUG && BX_CONFIG_SUPPORTS_THREADING) #endif // BGFX_CONFIG_MEMORY_TRACKING + const size_t kNaturalAlignment = 8; + class AllocatorStub : public bx::AllocatorI { public: @@ -165,7 +167,7 @@ namespace bgfx { if (NULL != _ptr) { - if (BX_CONFIG_ALLOCATOR_NATURAL_ALIGNMENT >= _align) + if (kNaturalAlignment >= _align) { #if BGFX_CONFIG_MEMORY_TRACKING { @@ -187,7 +189,7 @@ namespace bgfx } else if (NULL == _ptr) { - if (BX_CONFIG_ALLOCATOR_NATURAL_ALIGNMENT >= _align) + if (kNaturalAlignment >= _align) { #if BGFX_CONFIG_MEMORY_TRACKING { @@ -203,7 +205,7 @@ namespace bgfx return bx::alignedAlloc(this, _size, _align, _file, _line); } - if (BX_CONFIG_ALLOCATOR_NATURAL_ALIGNMENT >= _align) + if (kNaturalAlignment >= _align) { #if BGFX_CONFIG_MEMORY_TRACKING if (NULL == _ptr) diff --git a/src/renderer_vk.cpp b/src/renderer_vk.cpp index 410313c67..620f48b4c 100644 --- a/src/renderer_vk.cpp +++ b/src/renderer_vk.cpp @@ -332,7 +332,7 @@ VK_IMPORT_DEVICE return; } - bx::alignedFree(g_allocator, _memory, BX_CONFIG_ALLOCATOR_NATURAL_ALIGNMENT); + bx::alignedFree(g_allocator, _memory, 8); } static void VKAPI_PTR internalAllocationNotification(void* _userData, size_t _size, VkInternalAllocationType _allocationType, VkSystemAllocationScope _allocationScope)