todo: added memory leak examples
This commit is contained in:
parent
f4712ef5bf
commit
f50c36c84f
66
todo.txt
66
todo.txt
|
@ -51,3 +51,69 @@ MEMORY LEAKS
|
|||
|
||||
User configurable.
|
||||
|
||||
|
||||
|
||||
void f()
|
||||
{
|
||||
struct ABC *abc;
|
||||
|
||||
try
|
||||
{
|
||||
abc = new ABC;
|
||||
abc->a = new char[10];
|
||||
|
||||
delete [] abc->a;
|
||||
delete abc;
|
||||
}
|
||||
catch (...) {}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void f1()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
struct ABC *abc = new ABC;
|
||||
abc->a = new char[10];
|
||||
if ( ! abc->a )
|
||||
break;
|
||||
delete [] abc->a;
|
||||
delete abc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void f2()
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
struct ABC *abc = new ABC;
|
||||
abc->a = new char[10];
|
||||
if ( ! abc->a )
|
||||
break;
|
||||
delete [] abc->a;
|
||||
delete abc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void foo()
|
||||
{
|
||||
struct ABC *abc = new ABC;
|
||||
abc->a = new char[10];
|
||||
if ( ! abc->a )
|
||||
goto end;
|
||||
delete [] abc->a;
|
||||
delete abc;
|
||||
end:
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue