Click to See Complete Forum and Search --> : Scopes bug?


zlodziej
September 5th, 2005, 11:17 AM
Take a look at the piece of code:




APPGETTERLIST lpVirtPluginsList;

int APP_init()
{
// add virtual plugins
lpVirtPluginsList = new APPGETTERLIST;
appLoadVirtPlugins(lpVirtPluginsList);

}

void APP_quit()
{

{
APPGETTERLIST::iterator iter = lpVirtPluginsList->begin();
for( ; iter != lpVirtPluginsList->end(); ++iter)
{
delete (* iter);
}
}
delete lpVirtPluginsList;
}

Everything goes fine. But when I change APP_quit() function to act like this

void APP_quit()
{

{
APPGETTERLIST::iterator iter = lpVirtPluginsList->begin();
for( ; iter != lpVirtPluginsList->end(); ++iter)
{
delete (* iter);
}
}
delete lpVirtPluginsList;
}

after close my progmra will stay in memory? What I don't know in C++? Could it be VC++7 compiler error?

Eli Gassert
September 5th, 2005, 11:22 AM
You pasted the exact same thing twice in your "before" and "after" code blocks. What changed that amkes your program stay in memory?

Siddhartha
September 5th, 2005, 11:23 AM
APPGETTERLIST lpVirtPluginsList;

int APP_init()
{
// add virtual plugins
lpVirtPluginsList = new APPGETTERLIST;
appLoadVirtPlugins(lpVirtPluginsList);

}

void APP_quit()
{

{
APPGETTERLIST::iterator iter = lpVirtPluginsList->begin();
for( ; iter != lpVirtPluginsList->end(); ++iter)
{
delete (* iter);
}
}
delete lpVirtPluginsList;
}

Everything goes fine. But when I change APP_quit() function to act like this

void APP_quit()
{

{
APPGETTERLIST::iterator iter = lpVirtPluginsList->begin();
for( ; iter != lpVirtPluginsList->end(); ++iter)
{
delete (* iter);
}
}
delete lpVirtPluginsList;
}
What is APPGETTERLIST?

I cannot see any difference between the changed code and the original.
after close my progmra will stay in memory?
When your application quits, nothing of it will be left in memory. (though this is no reason to permit resource leaks.)