From d6f16bfa14a0a46ab2d0aff697969ae051968181 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Tue, 22 May 2018 03:39:19 +0200 Subject: Follow cppcheck suggestions --- tests/main.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'tests/main.cpp') diff --git a/tests/main.cpp b/tests/main.cpp index 6a74548..17348c4 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -384,6 +384,22 @@ void testMemoryUsage() } } +pair> __attribute__((optimize("O0"))) getDataNoCopy() +{ + u8 *decryptionKeyRawCopy = new u8[1024 * 1024 * 64]; + memcpy(decryptionKeyRawCopy, "hello, world!", 14); + shared_ptr decryptionKey = make_shared(decryptionKeyRawCopy, ENCRYPTION_KEY_BYTE_SIZE); + return make_pair(true, decryptionKey); +} + +void __attribute__((optimize("O0"))) testMemoryLeak() +{ + { + auto data = getDataNoCopy(); + printf("data: %s\n", data.second->data); + } +} + struct Test { function testFunc; @@ -396,6 +412,7 @@ int main(int argc, char **argv) testByName["standard"] = { testStandard, false }; testByName["two_local_nodes"] = { testTwoLocalNodes, false }; testByName["memory_usage"] = { testMemoryUsage, true }; + testByName["test_memory_leak"] = { testMemoryLeak, true }; const char *testName = "all"; if(argc > 1) -- cgit v1.2.3