aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2018-05-22 03:39:19 +0200
committerdec05eba <dec05eba@protonmail.com>2020-08-18 23:25:46 +0200
commitd6f16bfa14a0a46ab2d0aff697969ae051968181 (patch)
treee813258b43e35d7dfccff537010884e90683fda0 /tests
parentac626d47ebd49188458d70f98c6d871b1b7e3f50 (diff)
Follow cppcheck suggestions
Diffstat (limited to 'tests')
-rw-r--r--tests/main.cpp17
1 files changed, 17 insertions, 0 deletions
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<bool, shared_ptr<OwnedByteArray>> __attribute__((optimize("O0"))) getDataNoCopy()
+{
+ u8 *decryptionKeyRawCopy = new u8[1024 * 1024 * 64];
+ memcpy(decryptionKeyRawCopy, "hello, world!", 14);
+ shared_ptr<OwnedByteArray> decryptionKey = make_shared<OwnedByteArray>(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<void()> 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)