Cppcheck report as an error "Mismatching allocation and deallocation: cname" for the line with delete cname;
. I don't see what the problem with using my version of code is - it looks working.
Is my code wrong? How do I fix it? And what are the consequences of using my code?
if ( lenght != 0 )
{
char *cname = new char[lenght+1];
inbin.read(reinterpret_cast<char *>( cname ), lenght );
cname[lenght] = '\0';
*ptr_string = cname;
delete cname;
}