todo: added memory leak examples

This commit is contained in:
Daniel Marjamäki 2008-11-10 18:52:15 +00:00
parent f4712ef5bf
commit f50c36c84f
1 changed files with 66 additions and 0 deletions

View File

@ -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:
}