Skip to content

Commit

Permalink
fixed crash in release
Browse files Browse the repository at this point in the history
  • Loading branch information
nem0 committed Oct 10, 2020
1 parent e1c5bf8 commit 6bd6368
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/engine/allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace Lumix
ASSERT(n <= SMALL_ALLOC_MAX_SIZE);
#ifdef _WIN32
unsigned long res;
_BitScanReverse(&res, ((unsigned long)n - 1) >> 2);
return _BitScanReverse(&res, ((unsigned long)n - 1) >> 2) ? res : 0;
return u32(res);
#else
return 31 - __builtin_clz((n - 1) >> 2);
Expand Down Expand Up @@ -91,7 +91,7 @@ namespace Lumix

static void* allocSmall(DefaultAllocator& allocator, size_t n) {
const u32 bin = sizeToBin(n);

MutexGuard guard(allocator.m_mutex);
DefaultAllocator::Page* p = allocator.m_free_lists[bin];
if (!p) {
Expand Down Expand Up @@ -132,6 +132,7 @@ namespace Lumix
DefaultAllocator::DefaultAllocator() {
m_small_allocations = (u8*)OS::memReserve(PAGE_SIZE * MAX_PAGE_COUNT);
m_page_count = 0;
memset(m_free_lists, 0, sizeof(m_free_lists));
}

DefaultAllocator::~DefaultAllocator() {
Expand Down

0 comments on commit 6bd6368

Please sign in to comment.