From 4941565f1875cfd58146cd17029114b7d57c1062 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Mon, 7 Jan 2008 07:30:48 +0000 Subject: [PATCH] narrowed down valgrind complaints by adding SH_REMOVE to all the test cases --HG-- branch : sourcemm-1.4.3 extra : convert_revision : svn%3Ac2935e3e-5518-0410-8daf-afa5dab7d4e3/branches/sourcemm-1.4.3%40609 --- sourcehook/test/testbail.cpp | 4 ++++ sourcehook/test/testbail.h | 1 + sourcehook/test/testbail2.cpp | 13 +++++++++++++ sourcehook/test/testmulti.cpp | 5 +++-- sourcehook/test/testrecall.cpp | 6 ++++++ sourcehook/test/testref.cpp | 2 ++ sourcehook/test/testrefret.cpp | 8 ++++++++ 7 files changed, 37 insertions(+), 2 deletions(-) diff --git a/sourcehook/test/testbail.cpp b/sourcehook/test/testbail.cpp index d86f0c3..ebb6d92 100644 --- a/sourcehook/test/testbail.cpp +++ b/sourcehook/test/testbail.cpp @@ -109,6 +109,10 @@ bool TestBail(std::string &error) new State_EatYams_Return(6), NULL), "Part 6"); + SH_REMOVE_HOOK_STATICFUNC(IGaben, EatYams, g_Gabgab, EatYams_Handler1, false); + + UntestBail2(); + delete g_Gabgab; return true; diff --git a/sourcehook/test/testbail.h b/sourcehook/test/testbail.h index 258a49c..f0eed7c 100644 --- a/sourcehook/test/testbail.h +++ b/sourcehook/test/testbail.h @@ -28,6 +28,7 @@ namespace N_TestBail extern IGaben *g_Gabgab; bool TestBail2(std::string &error); + void UntestBail2(); } using namespace N_TestBail; diff --git a/sourcehook/test/testbail2.cpp b/sourcehook/test/testbail2.cpp index 3c5db52..d1d6d3c 100644 --- a/sourcehook/test/testbail2.cpp +++ b/sourcehook/test/testbail2.cpp @@ -5,6 +5,7 @@ #include "sourcehook_test.h" #include "testbail.h" +static unsigned int n_calls = 0; int EatYams_Handler2(int a) { @@ -31,6 +32,18 @@ namespace N_TestBail CHECK_COND(ret == 6, "Part 2.1"); + n_calls++; + return true; } + + void UntestBail2() + { + while (n_calls) + { + SH_REMOVE_HOOK_STATICFUNC(IGaben, EatYams, g_Gabgab, EatYams_Handler3, false); + SH_REMOVE_HOOK_STATICFUNC(IGaben, EatYams, g_Gabgab, EatYams_Handler2, false); + n_calls--; + } + } } diff --git a/sourcehook/test/testmulti.cpp b/sourcehook/test/testmulti.cpp index 2e4ca9a..95e7490 100644 --- a/sourcehook/test/testmulti.cpp +++ b/sourcehook/test/testmulti.cpp @@ -94,9 +94,9 @@ bool TestMulti(std::string &error) } } - for (unsigned int i=1; i<10; i++) + for (unsigned int i=0; i<10; i++) { - SH_REMOVE_HOOK_STATICFUNC(VMultiTest, HookTarget, pv[1], HookFunction, false); + SH_REMOVE_HOOK_STATICFUNC(VMultiTest, HookTarget, pv[i], HookFunction, false); delete pv[i]; } @@ -104,3 +104,4 @@ bool TestMulti(std::string &error) return true; } + diff --git a/sourcehook/test/testrecall.cpp b/sourcehook/test/testrecall.cpp index a80ad1b..25eede5 100644 --- a/sourcehook/test/testrecall.cpp +++ b/sourcehook/test/testrecall.cpp @@ -222,5 +222,11 @@ bool TestRecall(std::string &error) CHECK_COND(a == 0xDEADFC, "Part 5.1"); + SH_REMOVE_HOOK_STATICFUNC(Test, Func2, ptr, HandlerPost_Func2, true); + SH_REMOVE_HOOK_STATICFUNC(Test, Func2, ptr, Handler2_Func2, false); + SH_REMOVE_HOOK_STATICFUNC(Test, Func2, ptr, Handler1_Func22, false); + SH_REMOVE_HOOK_STATICFUNC(Test, Func2, ptr, HandlerPost1_Func22, true); + SH_REMOVE_HOOK_STATICFUNC(Test, Func2, ptr, HandlerPost2_Func22, true); + return true; } diff --git a/sourcehook/test/testref.cpp b/sourcehook/test/testref.cpp index db5062a..1727bf5 100644 --- a/sourcehook/test/testref.cpp +++ b/sourcehook/test/testref.cpp @@ -159,5 +159,7 @@ bool TestRef(std::string &error) new State_Result(12), NULL), "Part 4"); + SH_REMOVE_HOOK_MEMFUNC(CHello, Func, &hello, &hook, &CHook::Func, false); + return true; } diff --git a/sourcehook/test/testrefret.cpp b/sourcehook/test/testrefret.cpp index 6853cf8..b2f9291 100644 --- a/sourcehook/test/testrefret.cpp +++ b/sourcehook/test/testrefret.cpp @@ -195,6 +195,14 @@ bool TestRefRet(std::string &error) &hook.m_Var), // override ret was hook.m_Var new State_Func2_Ret(&hook.m_Var), // really returned hook.m_Var NULL), "Part 7"); + + SH_REMOVE_HOOK_MEMFUNC(Test, Func2, &test, &hook, &CHook::Func2_Post1, true); + SH_REMOVE_HOOK_MEMFUNC(Test, Func2, &test, &hook, &CHook::Func2_Pre1, false); + SH_REMOVE_HOOK_MEMFUNC(Test, Func1, &test, &hook, &CHook::Func1_Pre1, false); + SH_REMOVE_HOOK_MEMFUNC(Test, Func1, &test, &hook, &CHook::Func1_Post1, true); + SH_REMOVE_HOOK_MEMFUNC(Test, Func1, &test, &hook, &CHook::Func1_Pre2, false); + SH_REMOVE_HOOK_MEMFUNC(Test, Func1, &test, &hook, &CHook::Func1_Post2, true); return true; } +