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 --- .../HeapInspector/Samples/Manual/ManualSample.cpp | 78 ++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 Minecraft.Client/PS3/PS3Extras/HeapInspector/Samples/Manual/ManualSample.cpp (limited to 'Minecraft.Client/PS3/PS3Extras/HeapInspector/Samples/Manual/ManualSample.cpp') diff --git a/Minecraft.Client/PS3/PS3Extras/HeapInspector/Samples/Manual/ManualSample.cpp b/Minecraft.Client/PS3/PS3Extras/HeapInspector/Samples/Manual/ManualSample.cpp new file mode 100644 index 00000000..34914717 --- /dev/null +++ b/Minecraft.Client/PS3/PS3Extras/HeapInspector/Samples/Manual/ManualSample.cpp @@ -0,0 +1,78 @@ +// ================================================================================================================================= +// This sample demonstrates how to use the Server API to send allocs, reallocs and frees directly to the client. It also shows +// how to configure multiple heaps. +// ================================================================================================================================= + +#include "../../Server/HeapInspectorServer.h" +#include + +using namespace HeapInspectorServer; + +void Wait(int a_MilliSeconds); + +std::vector GetHeapInfo() +{ + std::vector result; + HeapInfo heapInfo; + heapInfo.m_Description = "Heap1"; + heapInfo.m_Range.m_Min = 0; + heapInfo.m_Range.m_Max = 0x80000000 - 1; + result.push_back(heapInfo); + + heapInfo.m_Description = "Heap2"; + heapInfo.m_Range.m_Min = 0; + heapInfo.m_Range.m_Max = 0x80000000 - 1; + result.push_back(heapInfo); + + return result; +} + +void* Alloc(uint32 a_Size, int a_Heap) +{ + Mutation mutation = BeginAlloc(); + void* mem = malloc(a_Size); + EndAlloc(mutation, a_Heap, mem, a_Size, a_Size); + return mem; +} + +void Free(void* a_Block, int a_Heap) +{ + Mutation mutation = BeginFree(); + free(a_Block); + EndFree(mutation, a_Heap, a_Block); +} + +void* ReAlloc(void* a_OldBlock, uint32 a_Size, int a_Heap) +{ + Mutation mutation = BeginReAlloc(); + void* mem = realloc(a_OldBlock, a_Size); + EndReAlloc(mutation, a_Heap, a_OldBlock, mem, a_Size, a_Size); + return mem; +} + +void RunHeapInspectorServer() +{ + Initialise(GetHeapInfo(), 3000, WaitForConnection_Enabled); + + while (1) + { + void* mem1; + void* memB; + + mem1 = Alloc(16, 0); + memB = Alloc(1024, 1); + + Wait(100); + + void* mem2 = ReAlloc(mem1, 32, 0); + + Wait(100); + + Free(mem2, 0); + Free(memB, 1); + + Wait(100); + } + + Shutdown(); +} -- cgit v1.2.3