mirror of
https://github.com/beefytech/Beef.git
synced 2025-07-04 15:26:00 +02:00
Moving BeefMem
This commit is contained in:
parent
b3487d733b
commit
65bf1915af
337 changed files with 0 additions and 4 deletions
|
@ -1,57 +0,0 @@
|
|||
#include "gperftools/src/tcmalloc.cc"
|
||||
|
||||
#include "BeefySysLib/Common.h"
|
||||
|
||||
#ifdef BFMEM_DYNAMIC
|
||||
#define BFMEM_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define BFMEM_EXPORT
|
||||
#endif
|
||||
|
||||
USING_NS_BF;
|
||||
|
||||
void PatchWindowsFunctions()
|
||||
{
|
||||
// For TCMalloc, don't really patch
|
||||
}
|
||||
|
||||
namespace tcmalloc
|
||||
{
|
||||
extern "C" int RunningOnValgrind(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
struct TCMallocRecord
|
||||
{
|
||||
void* mPtr;
|
||||
int mSize;
|
||||
};
|
||||
|
||||
static Array<TCMallocRecord> gTCMallocRecords;
|
||||
|
||||
void TCMalloc_RecordAlloc(void* ptr, int size)
|
||||
{
|
||||
TCMallocRecord mallocRecord = { ptr, size };
|
||||
gTCMallocRecords.push_back(mallocRecord);
|
||||
}
|
||||
|
||||
static void TCMalloc_FreeAllocs()
|
||||
{
|
||||
for (auto& record : gTCMallocRecords)
|
||||
{
|
||||
::VirtualFree(record.mPtr, 0, MEM_RELEASE);
|
||||
}
|
||||
gTCMallocRecords.Clear();
|
||||
}
|
||||
|
||||
extern "C" BFMEM_EXPORT void* BfmAlloc(int size, int align)
|
||||
{
|
||||
return tc_malloc(size);
|
||||
}
|
||||
|
||||
extern "C" BFMEM_EXPORT void BfmFree(void* ptr)
|
||||
{
|
||||
return tc_free(ptr);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue