Updated MemoryManager

Renamed MemoryLeakTracker[.hpp|.cpp] to MemoryManager[.hpp|.cpp]
Added MemoryManager::GetAllocatedBlockCount()
Added MemoryManager::GetAllocatedSize()
Optimized MemoryManager (no longer allocates a time buffer)


Former-commit-id: 0e9c720cbb48fbed7006db3bd1000ebbc22c9583
This commit is contained in:
Lynix
2014-04-21 22:13:31 +02:00
parent 77fc34ee7d
commit c606599e19
40 changed files with 179 additions and 190 deletions

View File

@@ -2,10 +2,8 @@
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_DEBUG_MEMORYLEAKTRACKER_HPP
#define NAZARA_DEBUG_MEMORYLEAKTRACKER_HPP
#ifndef NAZARA_DEBUG_MEMORYMANAGER_HPP
#define NAZARA_DEBUG_MEMORYMANAGER_HPP
#include <Nazara/Prerequesites.hpp>
#include <cstdio>
@@ -15,7 +13,12 @@ class NAZARA_API NzMemoryManager
{
public:
static void* Allocate(std::size_t size, bool multi, const char* file = nullptr, unsigned int line = 0);
static void Free(void* pointer, bool multi);
static unsigned int GetAllocatedBlockCount();
static std::size_t GetAllocatedSize();
static void NextFree(const char* file, unsigned int line);
private:
@@ -23,18 +26,18 @@ class NAZARA_API NzMemoryManager
~NzMemoryManager();
static void Initialize();
static char* TimeInfo();
static void TimeInfo(char buffer[23]);
static void Uninitialize();
};
NAZARA_API void* operator new(std::size_t size, const char* file, unsigned int line);
NAZARA_API void* operator new[](std::size_t size, const char* file, unsigned int line);
NAZARA_API void operator delete(void* ptr, const char* file, unsigned int line) throw();
NAZARA_API void operator delete[](void* ptr, const char* file, unsigned int line) throw();
NAZARA_API void operator delete(void* ptr, const char* file, unsigned int line) noexcept;
NAZARA_API void operator delete[](void* ptr, const char* file, unsigned int line) noexcept;
#endif // NAZARA_DEBUG_MEMORYLEAKTRACKER_HPP
#endif // NAZARA_DEBUG_MEMORYMANAGER_HPP
#ifndef NAZARA_DEBUG_MEMORYLEAKTRACKER_DISABLE_REDEFINITION
#ifndef NAZARA_DEBUG_MEMORYMANAGER_DISABLE_REDEFINITION
#define delete NzMemoryManager::NextFree(__FILE__, __LINE__), delete
#define new new(__FILE__, __LINE__)
#endif