the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1// =================================================================================================================================
2// This sample demonstrates how to use the Server API to send allocs, reallocs and frees directly to the client. It also shows
3// how to configure multiple heaps.
4// =================================================================================================================================
5
6#include "../../Server/HeapInspectorServer.h"
7#include <stdlib.h>
8
9using namespace HeapInspectorServer;
10
11void Wait(int a_MilliSeconds);
12
13std::vector<HeapInfo> GetHeapInfo()
14{
15 std::vector<HeapInfo> result;
16 HeapInfo heapInfo;
17 heapInfo.m_Description = "Heap1";
18 heapInfo.m_Range.m_Min = 0;
19 heapInfo.m_Range.m_Max = 0x80000000 - 1;
20 result.push_back(heapInfo);
21
22 heapInfo.m_Description = "Heap2";
23 heapInfo.m_Range.m_Min = 0;
24 heapInfo.m_Range.m_Max = 0x80000000 - 1;
25 result.push_back(heapInfo);
26
27 return result;
28}
29
30void* Alloc(uint32 a_Size, int a_Heap)
31{
32 Mutation mutation = BeginAlloc();
33 void* mem = malloc(a_Size);
34 EndAlloc(mutation, a_Heap, mem, a_Size, a_Size);
35 return mem;
36}
37
38void Free(void* a_Block, int a_Heap)
39{
40 Mutation mutation = BeginFree();
41 free(a_Block);
42 EndFree(mutation, a_Heap, a_Block);
43}
44
45void* ReAlloc(void* a_OldBlock, uint32 a_Size, int a_Heap)
46{
47 Mutation mutation = BeginReAlloc();
48 void* mem = realloc(a_OldBlock, a_Size);
49 EndReAlloc(mutation, a_Heap, a_OldBlock, mem, a_Size, a_Size);
50 return mem;
51}
52
53void RunHeapInspectorServer()
54{
55 Initialise(GetHeapInfo(), 3000, WaitForConnection_Enabled);
56
57 while (1)
58 {
59 void* mem1;
60 void* memB;
61
62 mem1 = Alloc(16, 0);
63 memB = Alloc(1024, 1);
64
65 Wait(100);
66
67 void* mem2 = ReAlloc(mem1, 32, 0);
68
69 Wait(100);
70
71 Free(mem2, 0);
72 Free(memB, 1);
73
74 Wait(100);
75 }
76
77 Shutdown();
78}