From 0be31ec97770dc333a1d9677407968fa9da850eb Mon Sep 17 00:00:00 2001 From: xtremegamer1 Date: Thu, 13 Oct 2022 19:03:43 -0600 Subject: [PATCH] Added an extremely simple memory leak tracker --- include/uc_allocation_tracker.hpp | 6 ++++++ src/uc_allocation_tracker.cpp | 15 +++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 include/uc_allocation_tracker.hpp create mode 100644 src/uc_allocation_tracker.cpp diff --git a/include/uc_allocation_tracker.hpp b/include/uc_allocation_tracker.hpp new file mode 100644 index 0000000..8dd1aa2 --- /dev/null +++ b/include/uc_allocation_tracker.hpp @@ -0,0 +1,6 @@ +#include + +extern int g_allocation_tracker; + +uc_err uct_context_alloc(uc_engine *uc, uc_context **context); +uc_err uct_context_free(uc_context *context); \ No newline at end of file diff --git a/src/uc_allocation_tracker.cpp b/src/uc_allocation_tracker.cpp new file mode 100644 index 0000000..076c208 --- /dev/null +++ b/src/uc_allocation_tracker.cpp @@ -0,0 +1,15 @@ +#include +#include + +int g_allocation_tracker; + +uc_err uct_context_alloc(uc_engine *uc, uc_context **context) +{ + std::printf("Allocations: %p\n", ++g_allocation_tracker); + return uc_context_alloc(uc, context); +} +uc_err uct_context_free(uc_context *context) +{ + std::printf("Allocations: %p\n", --g_allocation_tracker); + return uc_context_free(context); +} \ No newline at end of file