Avoid memory wastage

This tip submitted by Arthi on 2005-04-06 04:47:31. It has been viewed 46938 times.
Rating of 5.4 with 285 votes



Clean up memory spaces that are no longer used.

function_t(int val)
{
char *msg = new char[30];

if(val == VALID)
{
//do processing....
}
else
{
//don't just return.clean the memory that was alloted.
delete [] msg;
return false;
}
}



More tips

Help your fellow programmers! Add a tip!