MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / getAllocationType

Method getAllocationType

test/testmemleak.cpp:3027–3056  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3025 }
3026
3027 void getAllocationType() {
3028 // #7845
3029 check("class Thing { Thing(); };\n"
3030 "Thing * makeThing() { Thing *thing = new Thing; return thing; }\n"
3031 "\n"
3032 "void f() {\n"
3033 " makeThing();\n"
3034 "}");
3035 ASSERT_EQUALS("", errout_str());
3036
3037 // #10631
3038 check("struct Thing {\n"
3039 " Thing();\n"
3040 "};\n"
3041 "std::vector<Thing*> g_things;\n"
3042 "Thing* makeThing() {\n"
3043 " Thing* n = new Thing();\n"
3044 " return n;\n"
3045 "}\n"
3046 "Thing::Thing() {\n"
3047 " g_things.push_back(this);\n"
3048 "}\n"
3049 "void f() {\n"
3050 " makeThing();\n"
3051 " for(Thing* t : g_things) {\n"
3052 " delete t;\n"
3053 " }\n"
3054 "}\n");
3055 ASSERT_EQUALS("", errout_str());
3056 }
3057
3058 void crash1() { // #10729
3059 check("void foo() {\n"

Callers 1

openMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected