1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-07-04 23:36:00 +02:00

Fixed crash related to global var alignment

This commit is contained in:
Brian Fiete 2020-04-03 12:32:42 -07:00
parent 2c6a72ba68
commit aaccaa97e2
5 changed files with 40 additions and 10 deletions

View file

@ -5,11 +5,17 @@
#include "../Common.h"
//#define BUMPALLOC_TRACKALLOCS
//#define BUMPALLOC_STOMPALLOC
#ifdef BUMPALLOC_ETW_TRACING
#include "VSCustomNativeHeapEtwProvider.h"
#endif
#ifdef BUMPALLOC_STOMPALLOC
void* StompAlloc(int size);
void StompFree(void* addr);
#endif
#ifdef BUMPALLOC_TRACKALLOCS
#include "Dictionary.h"
#endif
@ -74,7 +80,11 @@ public:
mCurAlloc = NULL;
mCurPtr = (uint8*)(intptr)ALLOC_SIZE;
for (auto ptr : mPools)
#ifdef BUMPALLOC_STOMPALLOC
StompFree(ptr);
#else
free(ptr);
#endif
mPools.Clear();
mSizes.Clear();
mCurChunkNum = -1;
@ -130,7 +140,11 @@ public:
int curSize = (int)(mCurPtr - mCurAlloc);
mPrevSizes += curSize;
mSizes.push_back(curSize);
mCurAlloc = (uint8*)malloc(ALLOC_SIZE);
#ifdef BUMPALLOC_STOMPALLOC
mCurAlloc = (uint8*)StompAlloc(ALLOC_SIZE);
#else
mCurAlloc = (uint8*)malloc(ALLOC_SIZE);
#endif
memset(mCurAlloc, 0, ALLOC_SIZE);
mPools.push_back(mCurAlloc);
mCurPtr = mCurAlloc;
@ -205,7 +219,11 @@ public:
if (wantSize > ALLOC_SIZE / 2)
{
#ifdef BUMPALLOC_STOMPALLOC
uint8* bigData = (uint8*)StompAlloc((int)wantSize);
#else
uint8* bigData = (uint8*)malloc(wantSize);
#endif
memset(bigData, 0, wantSize);
mPools.push_back(bigData);
return bigData;