CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Scopes bug?

  1. #1
    Join Date
    Sep 2005
    Posts
    15

    Thumbs down Scopes bug?

    Take a look at the piece of code:


    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
    Code:
    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?

  2. #2
    Join Date
    Apr 2002
    Location
    PA, USA
    Posts
    1,658

    Re: Scopes bug?

    You pasted the exact same thing twice in your "before" and "after" code blocks. What changed that amkes your program stay in memory?
    =--=--=--=--=--=--=--=--=--=--=--=--=--=
    Please rate this post to show your appreciation for those that helped you.

    Before You Post A Question, Please Read This: How & When To Ask Your Question
    =--=--=--=--=--=--=--=--=--=--=--=--=--=

    -eli
    http://www.toad-software.com
    http://www.dailymission.com - Do It Daily

  3. #3
    Join Date
    Oct 2002
    Location
    Germany
    Posts
    6,205

    Re: Scopes bug?

    Quote Originally Posted by zlodziej
    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
    Code:
    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.
    Quote Originally Posted by zlodziej
    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.)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured