From b691c43c44ff180d10e7d4a9afc83b98551ff586 Mon Sep 17 00:00:00 2001
From: daoge_cmd <3523206925@qq.com>
Date: Sun, 1 Mar 2026 12:16:08 +0800
Subject: Initial commit
---
.../Samples/ReplaceNewDelete/PS3/Main.cpp | 7 +
.../PS3/ReplaceNewDeleteSample.vcproj | 183 +++++++++++++++++++++
.../PS3/ReplaceNewDeleteSample.vcxproj | 70 ++++++++
.../Samples/ReplaceNewDelete/PS3/Wait.cpp | 6 +
.../ReplaceNewDelete/ReplaceNewDeleteSample.cpp | 67 ++++++++
5 files changed, 333 insertions(+)
create mode 100644 Minecraft.Client/PS3/PS3Extras/HeapInspector/Samples/ReplaceNewDelete/PS3/Main.cpp
create mode 100644 Minecraft.Client/PS3/PS3Extras/HeapInspector/Samples/ReplaceNewDelete/PS3/ReplaceNewDeleteSample.vcproj
create mode 100644 Minecraft.Client/PS3/PS3Extras/HeapInspector/Samples/ReplaceNewDelete/PS3/ReplaceNewDeleteSample.vcxproj
create mode 100644 Minecraft.Client/PS3/PS3Extras/HeapInspector/Samples/ReplaceNewDelete/PS3/Wait.cpp
create mode 100644 Minecraft.Client/PS3/PS3Extras/HeapInspector/Samples/ReplaceNewDelete/ReplaceNewDeleteSample.cpp
(limited to 'Minecraft.Client/PS3/PS3Extras/HeapInspector/Samples/ReplaceNewDelete')
diff --git a/Minecraft.Client/PS3/PS3Extras/HeapInspector/Samples/ReplaceNewDelete/PS3/Main.cpp b/Minecraft.Client/PS3/PS3Extras/HeapInspector/Samples/ReplaceNewDelete/PS3/Main.cpp
new file mode 100644
index 00000000..06429da3
--- /dev/null
+++ b/Minecraft.Client/PS3/PS3Extras/HeapInspector/Samples/ReplaceNewDelete/PS3/Main.cpp
@@ -0,0 +1,7 @@
+
+void RunHeapInspectorServer();
+
+int main(int /*a_ArgC*/, const char* /*a_ArgV[]*/)
+{
+ RunHeapInspectorServer();
+}
diff --git a/Minecraft.Client/PS3/PS3Extras/HeapInspector/Samples/ReplaceNewDelete/PS3/ReplaceNewDeleteSample.vcproj b/Minecraft.Client/PS3/PS3Extras/HeapInspector/Samples/ReplaceNewDelete/PS3/ReplaceNewDeleteSample.vcproj
new file mode 100644
index 00000000..84a9be14
--- /dev/null
+++ b/Minecraft.Client/PS3/PS3Extras/HeapInspector/Samples/ReplaceNewDelete/PS3/ReplaceNewDeleteSample.vcproj
@@ -0,0 +1,183 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Minecraft.Client/PS3/PS3Extras/HeapInspector/Samples/ReplaceNewDelete/PS3/ReplaceNewDeleteSample.vcxproj b/Minecraft.Client/PS3/PS3Extras/HeapInspector/Samples/ReplaceNewDelete/PS3/ReplaceNewDeleteSample.vcxproj
new file mode 100644
index 00000000..9515f936
--- /dev/null
+++ b/Minecraft.Client/PS3/PS3Extras/HeapInspector/Samples/ReplaceNewDelete/PS3/ReplaceNewDeleteSample.vcxproj
@@ -0,0 +1,70 @@
+
+
+
+
+ Debug
+ PS3
+
+
+ Release
+ PS3
+
+
+
+
+
+
+
+
+ {B0416FCD-A32B-4F91-93D1-4EDFF99F740B}
+
+
+
+ Application
+ GCC
+
+
+ Application
+ GCC
+
+
+
+
+
+
+
+
+
+
+
+
+ $(ProjectDir)$(Platform)_$(Configuration)_VS2010\
+ $(Platform)_$(Configuration)_VS2010\
+
+
+ $(ProjectDir)$(Platform)_$(Configuration)_VS2010\
+ $(Platform)_$(Configuration)_VS2010\
+
+
+
+ _DEBUG;__CELL_ASSERT__;%(PreprocessorDefinitions);;HEAPINSPECTOR_PS3=1
+ true
+
+
+ "$(SCE_PS3_ROOT)\target\ppu\lib\libm.a";"$(SCE_PS3_ROOT)\target\ppu\lib\libio_stub.a";"..\..\..\Server\PS3\Debug\libHeapInspectorServer.a";"$(SCE_PS3_ROOT)\target\ppu\lib\libpthread.a";"$(SCE_PS3_ROOT)\target\ppu\lib\libnet_stub.a";"$(SCE_PS3_ROOT)\target\ppu\lib\libsysmodule_stub.a";%(AdditionalDependencies)
+
+
+
+
+ NDEBUG;%(PreprocessorDefinitions);;HEAPINSPECTOR_PS3=1
+ Level2
+
+
+ "..\..\..\Server\PS3\Release\libHeapInspectorServer.a";"$(SCE_PS3_ROOT)\target\ppu\lib\libpthread.a";"$(SCE_PS3_ROOT)\target\ppu\lib\libnet_stub.a";"$(SCE_PS3_ROOT)\target\ppu\lib\libsysmodule_stub.a";%(AdditionalDependencies)
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Minecraft.Client/PS3/PS3Extras/HeapInspector/Samples/ReplaceNewDelete/PS3/Wait.cpp b/Minecraft.Client/PS3/PS3Extras/HeapInspector/Samples/ReplaceNewDelete/PS3/Wait.cpp
new file mode 100644
index 00000000..2c436c84
--- /dev/null
+++ b/Minecraft.Client/PS3/PS3Extras/HeapInspector/Samples/ReplaceNewDelete/PS3/Wait.cpp
@@ -0,0 +1,6 @@
+#include
+
+void Wait(int a_Milliseconds)
+{
+ sys_timer_usleep(a_Milliseconds * 1000);
+}
\ No newline at end of file
diff --git a/Minecraft.Client/PS3/PS3Extras/HeapInspector/Samples/ReplaceNewDelete/ReplaceNewDeleteSample.cpp b/Minecraft.Client/PS3/PS3Extras/HeapInspector/Samples/ReplaceNewDelete/ReplaceNewDeleteSample.cpp
new file mode 100644
index 00000000..305d589b
--- /dev/null
+++ b/Minecraft.Client/PS3/PS3Extras/HeapInspector/Samples/ReplaceNewDelete/ReplaceNewDeleteSample.cpp
@@ -0,0 +1,67 @@
+// =================================================================================================================================
+// This sample demonstrates how to replace operator new and delete and how to send these allocations to the HeapInspector client.
+// Please note that the Hook sample captures allocations on a lower level and will also trace all new/delete allocations.
+//
+// WARNING: Make sure that you replace both the array and non-array operators. If there are any pairing issues in your code
+// (allocating with new[] and deleting with delete), HeapInspector will miss those deallocations and that will be problematic
+// for a subsequent allocation on that address: it will then warn that it found a double allocation. That will actually be a
+// sign that the operators aren't properly matched.
+// =================================================================================================================================
+
+#include "../../Server/HeapInspectorServer.h"
+#include
+#include
+
+using namespace HeapInspectorServer;
+
+void Wait(int a_MilliSeconds);
+
+void* operator new(size_t a_Size)
+{
+ Mutation mutation = BeginAlloc();
+ void* mem = malloc(a_Size);
+ EndAlloc(mutation, 0, mem, a_Size, a_Size);
+ return mem;
+}
+
+void operator delete(void* a_Pointer)
+{
+ Mutation mutation = BeginFree();
+ free(a_Pointer);
+ EndFree(mutation, 0, a_Pointer);
+}
+
+void* operator new[](size_t a_Size)
+{
+ Mutation mutation = BeginAlloc();
+ void* mem = malloc(a_Size);
+ EndAlloc(mutation, 0, mem, a_Size, a_Size);
+ return mem;
+}
+
+void operator delete[](void* a_Pointer)
+{
+ Mutation mutation = BeginFree();
+ free(a_Pointer);
+ EndFree(mutation, 0, a_Pointer);
+}
+
+void RunHeapInspectorServer()
+{
+ Initialise(GetDefaultHeapInfo(), 3000, WaitForConnection_Enabled);
+
+ while (1)
+ {
+ int* xArray = new int[100];
+ float* y = new float;
+
+ Wait(100);
+
+ delete[] xArray;
+ delete y;
+
+ Wait(100);
+ }
+
+ Shutdown();
+}
--
cgit v1.2.3