Added MemoryManager::GetAllocationCount()
Former-commit-id: 32f4f0780fdd32ac72a7e94732958bdd688844c6
This commit is contained in:
parent
4ef5f6fb3d
commit
a3f877daf1
|
|
@ -18,6 +18,7 @@ class NAZARA_API NzMemoryManager
|
||||||
|
|
||||||
static unsigned int GetAllocatedBlockCount();
|
static unsigned int GetAllocatedBlockCount();
|
||||||
static std::size_t GetAllocatedSize();
|
static std::size_t GetAllocatedSize();
|
||||||
|
static unsigned int GetAllocationCount();
|
||||||
|
|
||||||
static void NextFree(const char* file, unsigned int line);
|
static void NextFree(const char* file, unsigned int line);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,8 @@ namespace
|
||||||
0,
|
0,
|
||||||
s_magic
|
s_magic
|
||||||
};
|
};
|
||||||
|
|
||||||
|
unsigned int s_allocationCount = 0;
|
||||||
unsigned int s_allocatedBlock = 0;
|
unsigned int s_allocatedBlock = 0;
|
||||||
std::size_t s_allocatedSize = 0;
|
std::size_t s_allocatedSize = 0;
|
||||||
|
|
||||||
|
|
@ -101,6 +103,7 @@ void* NzMemoryManager::Allocate(std::size_t size, bool multi, const char* file,
|
||||||
|
|
||||||
s_allocatedBlock++;
|
s_allocatedBlock++;
|
||||||
s_allocatedSize += size;
|
s_allocatedSize += size;
|
||||||
|
s_allocationCount++;
|
||||||
|
|
||||||
#if defined(NAZARA_PLATFORM_WINDOWS)
|
#if defined(NAZARA_PLATFORM_WINDOWS)
|
||||||
LeaveCriticalSection(&s_mutex);
|
LeaveCriticalSection(&s_mutex);
|
||||||
|
|
@ -133,20 +136,11 @@ void NzMemoryManager::Free(void* pointer, bool multi)
|
||||||
|
|
||||||
FILE* log = std::fopen(s_MLTFileName, "a");
|
FILE* log = std::fopen(s_MLTFileName, "a");
|
||||||
|
|
||||||
|
const char* error = (multi) ? "delete[] after new" : "delete after new[]";
|
||||||
if (s_nextFreeFile)
|
if (s_nextFreeFile)
|
||||||
{
|
std::fprintf(log, "%s Warning: %s at %s:%u\n", timeStr, error, s_nextFreeFile, s_nextFreeLine);
|
||||||
if (multi)
|
|
||||||
std::fprintf(log, "%s Warning: delete[] after new at %s:%u\n", timeStr, s_nextFreeFile, s_nextFreeLine);
|
|
||||||
else
|
else
|
||||||
std::fprintf(log, "%s Warning: delete after new[] at %s:%u\n", timeStr, s_nextFreeFile, s_nextFreeLine);
|
std::fprintf(log, "%s Warning: %s at unknown position\n", error, timeStr);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (multi)
|
|
||||||
std::fprintf(log, "%s Warning: delete[] after new at unknown position\n", timeStr);
|
|
||||||
else
|
|
||||||
std::fprintf(log, "%s Warning: delete after new[] at unknown position\n", timeStr);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::fclose(log);
|
std::fclose(log);
|
||||||
}
|
}
|
||||||
|
|
@ -180,6 +174,11 @@ std::size_t NzMemoryManager::GetAllocatedSize()
|
||||||
return s_allocatedSize;
|
return s_allocatedSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int NzMemoryManager::GetAllocationCount()
|
||||||
|
{
|
||||||
|
return s_allocationCount;
|
||||||
|
}
|
||||||
|
|
||||||
void NzMemoryManager::NextFree(const char* file, unsigned int line)
|
void NzMemoryManager::NextFree(const char* file, unsigned int line)
|
||||||
{
|
{
|
||||||
s_nextFreeFile = file;
|
s_nextFreeFile = file;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue