azmeuk
azmeuk

Reputation: 4506

Cppcheck : mismatchAllocDealloc error

I have checked my program with cppcheck, and it complains about some mismatchAllocDealloc errors. I don't really understand what I have done wrong. What's the meaning of this error ?

Thank you

Upvotes: 2

Views: 551

Answers (1)

Daniel Marjamäki
Daniel Marjamäki

Reputation: 3037

I am a Cppcheck author.

Example code:

p1 = malloc(10);
delete p1;  // <- should use "free(p1)"

p2 = new char[10];
free(p2);   // <- should use "delete[] p2"

etc

Upvotes: 6

Related Questions