Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions OpenJPOG/Source/AOptions.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#include "AOptions.h"
#include "PPropertyParser/PPropertyReader.h"

//-----------------------------------------------------------------------------
// Enables memory debugging.
// Note: Should be the last include!
//-----------------------------------------------------------------------------
#include <TKernel/TMemoryDebugOn.h>

TOSHI_NAMESPACE_USING

TPCCHAR AOptions::sm_szOptionsDir = TNULL;
Expand Down
6 changes: 6 additions & 0 deletions OpenJPOG/Source/ARenderer.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#include "ARenderer.h"
#include "main.h"

//-----------------------------------------------------------------------------
// Enables memory debugging.
// Note: Should be the last include!
//-----------------------------------------------------------------------------
#include <TKernel/TMemoryDebugOn.h>

TOSHI_NAMESPACE_USING

IMPLEMENT_DYNCREATE(ARenderer, TTask)
Expand Down
6 changes: 6 additions & 0 deletions OpenJPOG/Source/ASoundManager.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#include "ASoundManager.h"

//-----------------------------------------------------------------------------
// Enables memory debugging.
// Note: Should be the last include!
//-----------------------------------------------------------------------------
#include <TKernel/TMemoryDebugOn.h>

TOSHI_NAMESPACE_USING

IMPLEMENT_DYNCREATE(ASoundManager, TObject);
Expand Down
6 changes: 6 additions & 0 deletions OpenJPOG/Source/AVibrationManager.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#include "AVibrationManager.h"

//-----------------------------------------------------------------------------
// Enables memory debugging.
// Note: Should be the last include!
//-----------------------------------------------------------------------------
#include <TKernel/TMemoryDebugOn.h>

TOSHI_NAMESPACE_USING

IMPLEMENT_DYNCREATE(AVibrationManager, TTask);
6 changes: 6 additions & 0 deletions OpenJPOG/Source/GUI/AGUIGameHUD.cpp
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
#include "AGUIGameHUD.h"

//-----------------------------------------------------------------------------
// Enables memory debugging.
// Note: Should be the last include!
//-----------------------------------------------------------------------------
#include <TKernel/TMemoryDebugOn.h>
6 changes: 6 additions & 0 deletions OpenJPOG/Source/GUI/AGUISystem.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#include "AGUISystem.h"
#include "main.h"

//-----------------------------------------------------------------------------
// Enables memory debugging.
// Note: Should be the last include!
//-----------------------------------------------------------------------------
#include <TKernel/TMemoryDebugOn.h>

TOSHI_NAMESPACE_USING

IMPLEMENT_DYNCREATE(AGUISystem, TTask)
Expand Down
8 changes: 7 additions & 1 deletion OpenJPOG/Source/Movie/ABINKMoviePlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
#include "TKernel/TManagedPointer.h"
#include "TRenderD3D/TRenderD3DInterface.h"

//-----------------------------------------------------------------------------
// Enables memory debugging.
// Note: Should be the last include!
//-----------------------------------------------------------------------------
#include <TKernel/TMemoryDebugOn.h>

TOSHI_NAMESPACE_USING

static U32 s_iPlayForegroundFast = 0;
Expand Down Expand Up @@ -207,7 +213,7 @@ TBOOL ABINKMoviePlayer::InitializeVideoResource()
textureFormatSize = 8;
}
size *= 256 * 256;
TPVOID buffer = tmalloc(size, TNULL, -1);
TPVOID buffer = tmalloc(size);
TSystem::MemSet(buffer, 0xFF, size);
m_pTextures[2] = factory->CreateEx(buffer, size, 256, 256, 1, textureFormat, textureFormatSize);
m_pTextures[2]->SetAddressModeMode(TTextureResource::ADDRESSMODE_CLAMP);
Expand Down
6 changes: 6 additions & 0 deletions OpenJPOG/Source/Movie/AMoviePlayer.cpp
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
#include "AMoviePlayer.h"

//-----------------------------------------------------------------------------
// Enables memory debugging.
// Note: Should be the last include!
//-----------------------------------------------------------------------------
#include <TKernel/TMemoryDebugOn.h>
6 changes: 6 additions & 0 deletions OpenJPOG/Source/States/AFrontEndSplashState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
#include "GUI/AGUISystem.h"
#include "main.h"

//-----------------------------------------------------------------------------
// Enables memory debugging.
// Note: Should be the last include!
//-----------------------------------------------------------------------------
#include <TKernel/TMemoryDebugOn.h>

TOSHI_NAMESPACE_USING

IMPLEMENT_DYNCREATE(AFrontEndSplashState, AFrontendState)
Expand Down
6 changes: 6 additions & 0 deletions OpenJPOG/Source/States/AFrontEndState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
#include "main.h"
#include "AGameState.h"

//-----------------------------------------------------------------------------
// Enables memory debugging.
// Note: Should be the last include!
//-----------------------------------------------------------------------------
#include <TKernel/TMemoryDebugOn.h>

TOSHI_NAMESPACE_USING

IMPLEMENT_DYNAMIC(AFrontendState, ARootState)
Expand Down
6 changes: 6 additions & 0 deletions OpenJPOG/Source/States/AGameState.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#include "AGameState.h"

//-----------------------------------------------------------------------------
// Enables memory debugging.
// Note: Should be the last include!
//-----------------------------------------------------------------------------
#include <TKernel/TMemoryDebugOn.h>

TOSHI_NAMESPACE_USING

IMPLEMENT_DYNCREATE(AGameState, ARootState)
6 changes: 6 additions & 0 deletions OpenJPOG/Source/States/ARootState.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#include "ARootState.h"

//-----------------------------------------------------------------------------
// Enables memory debugging.
// Note: Should be the last include!
//-----------------------------------------------------------------------------
#include <TKernel/TMemoryDebugOn.h>

TOSHI_NAMESPACE_USING

IMPLEMENT_DYNAMIC(ARootState, TObject)
Expand Down
6 changes: 6 additions & 0 deletions OpenJPOG/Source/Tasks/ADummyTask.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#include "ADummyTask.h"

//-----------------------------------------------------------------------------
// Enables memory debugging.
// Note: Should be the last include!
//-----------------------------------------------------------------------------
#include <TKernel/TMemoryDebugOn.h>

IMPLEMENT_DYNCREATE(ADummyTask, Toshi::TTask);
6 changes: 6 additions & 0 deletions OpenJPOG/Source/Tasks/AFrontEndController.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#include "AFrontEndController.h"

//-----------------------------------------------------------------------------
// Enables memory debugging.
// Note: Should be the last include!
//-----------------------------------------------------------------------------
#include <TKernel/TMemoryDebugOn.h>

IMPLEMENT_DYNCREATE(AFrontEndController, Toshi::TTask)
6 changes: 6 additions & 0 deletions OpenJPOG/Source/Tasks/ARootStateController.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#include "ARootStateController.h"

//-----------------------------------------------------------------------------
// Enables memory debugging.
// Note: Should be the last include!
//-----------------------------------------------------------------------------
#include <TKernel/TMemoryDebugOn.h>

TOSHI_NAMESPACE_USING

IMPLEMENT_DYNCREATE(ARootStateController, TTask);
Expand Down
6 changes: 6 additions & 0 deletions OpenJPOG/Source/Tasks/ARootTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
#include "main.h"
#include "States/AFrontEndSplashState.h"

//-----------------------------------------------------------------------------
// Enables memory debugging.
// Note: Should be the last include!
//-----------------------------------------------------------------------------
#include <TKernel/TMemoryDebugOn.h>

TOSHI_NAMESPACE_USING

IMPLEMENT_DYNCREATE(ARootTask, TTask);
Expand Down
6 changes: 6 additions & 0 deletions OpenJPOG/Source/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#include "main.h"
#include "TRender/TResource.h"

//-----------------------------------------------------------------------------
// Enables memory debugging.
// Note: Should be the last include!
//-----------------------------------------------------------------------------
#include <TKernel/TMemoryDebugOn.h>

AApplication g_oTheApp;

TBOOL AApplication::OnCreate(TINT argc, TPCHAR *const argv)
Expand Down
10 changes: 6 additions & 4 deletions Toshi/Include/TKernel/TFreeList.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
#if 1
# define DECLARE_FREELIST(class_name) \
public: \
static TPVOID TOSHI_API operator new(TUINT s, TPVOID mem) { return mem; } \
static TPVOID TOSHI_API operator new(TUINT s) { return ms_oFreeList.New(s); } \
static TPVOID TOSHI_API operator new(TUINT s, TPCHAR mem, TINT unk) { return ms_oFreeList.New(s); } \
static void TOSHI_API operator delete(void *ptr) { ms_oFreeList.Delete(ptr); } \
static TPVOID TOSHI_API operator new(TUINT s, TPVOID mem) noexcept { return mem; } \
static TPVOID TOSHI_API operator new(TUINT s) noexcept { return ms_oFreeList.New(s); } \
static TPVOID TOSHI_API operator new(TUINT s, TPCHAR mem, TINT unk) noexcept { return ms_oFreeList.New(s); } \
static void TOSHI_API operator delete(void *ptr) noexcept { ms_oFreeList.Delete(ptr); } \
static void operator delete(void *ptr, TPVOID mem) noexcept {} \
static Toshi::TFreeList &TOSHI_API GetFreeList() { return ms_oFreeList; } \
\
private: \
Expand All @@ -20,6 +21,7 @@
# define IMPLEMENT_FREELIST(class_name, InitialSize, GrowSize) \
Toshi::TFreeList class_name::ms_oFreeList = Toshi::TFreeList(sizeof(class_name), InitialSize, GrowSize, TNULL);
#endif

TOSHI_NAMESPACE_BEGIN

class TKERNELINTERFACE_EXPORTS TFreeList
Expand Down
2 changes: 1 addition & 1 deletion Toshi/Include/TKernel/TManagedPointer.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class TManagedPtr
template <typename P>
operator P *() const
{
static_assert(std::is_base_of<TRefCounted, P>::value);
static_assert(std::is_base_of<T, P>::value);

TASSERT(m_pObject != TNULL);
return (P *)m_pObject;
Expand Down
4 changes: 2 additions & 2 deletions Toshi/Include/TKernel/TMemory.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class TKERNELINTERFACE_EXPORTS TMemory
static MemNode *TOSHI_API GetMemNodeFromAddress(TPVOID a_pAddr);
static void TOSHI_API ExtendNodeSize(MemNode *a_pMemNode, TUINT a_iuSize);

TPVOID Alloc(TUINT a_uiSize, TUINT a_uiAlignment, MemBlock *a_pMemBlock, TPCHAR a_pBuffer, TINT a_iUnk3);
TPVOID Alloc(TUINT a_uiSize, TUINT a_uiAlignment, MemBlock *a_pMemBlock, TPCCHAR a_pszFileName, TINT a_iLineNum);
TBOOL Free(TPVOID a_pMem);

protected:
Expand All @@ -75,6 +75,6 @@ inline static TMemory g_oMemManager;

TOSHI_NAMESPACE_END

TPVOID TKERNELINTERFACE_EXPORTS TOSHI_API tmalloc(TINT a_iSize, TPCHAR a_pBuffer, TINT a_iUnk);
TPVOID TKERNELINTERFACE_EXPORTS TOSHI_API tmalloc(TINT a_iSize, TPCCHAR a_pszFileName = TNULL, TINT a_iLineNum = -1);
TPVOID TKERNELINTERFACE_EXPORTS TOSHI_API tmemalign(TINT a_iAlign, TINT a_iSize);
void TKERNELINTERFACE_EXPORTS TOSHI_API tfree(TPVOID a_pMem);
10 changes: 10 additions & 0 deletions Toshi/Include/TKernel/TMemoryDebug.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#pragma once
#include "TKernel/Defines.h"

#ifdef TKERNELINTERFACE_ENABLE_MEMORY_PROFILER

extern TKERNELINTERFACE_EXPORTS const TCHAR* TMemory__FUNC__;
extern TKERNELINTERFACE_EXPORTS const TCHAR* TMemory__FILE__;
extern TKERNELINTERFACE_EXPORTS TINT TMemory__LINE__;

#endif // TKERNELINTERFACE_ENABLE_MEMORY_PROFILER
14 changes: 14 additions & 0 deletions Toshi/Include/TKernel/TMemoryDebugOff.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//-----------------------------------------------------------------------------
// Include this file to disable memory debugging.
//
// Note: This file should be the last include in order to make sure it works.
// Include TMemoryDebugOn.h to enable debugging mode.
//-----------------------------------------------------------------------------

#ifdef TOSHI_PROFILER_MEMORY_ENABLED

# undef new
# undef tmalloc
# undef TOSHI_PROFILER_MEMORY_ENABLED

#endif // TOSHI_PROFILER_MEMORY_ENABLED
16 changes: 16 additions & 0 deletions Toshi/Include/TKernel/TMemoryDebugOn.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//-----------------------------------------------------------------------------
// Include this file to enable memory debugging if TKERNELINTERFACE_ENABLE_MEMORY_PROFILER is defined.
//
// Note: This file should be the last include in order to make sure it works.
// Include TMemoryDebugOff.h to disable debugging mode.
//-----------------------------------------------------------------------------

#if defined(TKERNELINTERFACE_ENABLE_MEMORY_PROFILER) && !defined(TOSHI_PROFILER_MEMORY_ENABLED)

# include "TMemoryDebug.h"

# define new ( TMemory__FUNC__ = __FUNCSIG__, TMemory__FILE__ = __FILE__, TMemory__LINE__ = __LINE__ ) && TFALSE ? TNULL : new
# define tmalloc(...) tmalloc(__VA_ARGS__, __FILE__, __LINE__)
# define TOSHI_PROFILER_MEMORY_ENABLED

#endif
2 changes: 1 addition & 1 deletion Toshi/Include/TRender/TShader.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class TRENDERINTERFACE_EXPORTS TMaterial : public TResource
m_iFlags |= a_uiFlag;
}
else {
m_iFlags &= -a_uiFlag;
m_iFlags &= ~a_uiFlag;
}
}
// $TRenderInterface: FUNCTION 100084f0
Expand Down
Loading