]> git.sesse.net Git - vlc/commitdiff
* modules/gui/skins2/*: fixed a whole bunch of memory leaks.
authorGildas Bazin <gbazin@videolan.org>
Thu, 16 Dec 2004 13:59:51 +0000 (13:59 +0000)
committerGildas Bazin <gbazin@videolan.org>
Thu, 16 Dec 2004 13:59:51 +0000 (13:59 +0000)
modules/gui/skins2/parser/interpreter.cpp
modules/gui/skins2/parser/xmlparser.cpp
modules/gui/skins2/src/theme.cpp
modules/gui/skins2/src/theme_loader.cpp
modules/gui/skins2/src/theme_repository.cpp
modules/gui/skins2/vars/playlist.cpp
modules/gui/skins2/x11/x11_display.cpp

index 5f75b8ebae7dc6299e9853db2f3cce868088883b..2b0d208a5bc7ae17e1180f6fc70e5201217f65e2 100644 (file)
@@ -186,14 +186,14 @@ VarBool *Interpreter::getVarBool( const string &rName, Theme *pTheme )
 {
     VarManager *pVarManager = VarManager::instance( getIntf() );
 
-   // Convert the expression into Reverse Polish Notation
-    ExprEvaluator *pEvaluator = new ExprEvaluator( getIntf() );
-    pEvaluator->parse( rName );
+    // Convert the expression into Reverse Polish Notation
+    ExprEvaluator evaluator( getIntf() );
+    evaluator.parse( rName );
 
     list<VarBool*> varStack;
 
     // Get the first token from the RPN stack
-    string token = pEvaluator->getToken();
+    string token = evaluator.getToken();
     while( !token.empty() )
     {
         if( token == "and" )
@@ -295,7 +295,7 @@ VarBool *Interpreter::getVarBool( const string &rName, Theme *pTheme )
             varStack.push_back( pVar );
         }
         // Get the first token from the RPN stack
-        token = pEvaluator->getToken();
+        token = evaluator.getToken();
     }
 
     // The stack should contain a single variable
index 37ff58e998dba7ebdd61be3ecffe15b17ead6e38..1d9734116d1394504b2b146648accc60d994d140 100644 (file)
@@ -149,11 +149,13 @@ bool XMLParser::parse()
                 }
 
                 handleBeginElement( eltName, attributes );
+                free( eltName );
 
                 map<const char*, const char*, ltstr> ::iterator it =
                     attributes.begin();
                 while( it != attributes.end() )
                 {
+                    free( (char *)it->first );
                     free( (char *)it->second );
                     it++;
                 }
index b91f6c0403026012c12f944e950077182a81ef1a..d244d9b394afb81f8ad422e0c7af8f7d7bbbb7c8 100755 (executable)
@@ -45,8 +45,7 @@ void Theme::loadConfig()
 
     // Get config from vlcrc file
     char *save = config_GetPsz( getIntf(), "skins2-config" );
-    if( save == NULL )
-        return;
+    if( !save ) return;
 
     // Initialization
     map<string, TopWindowPtr>::const_iterator it;
@@ -75,6 +74,7 @@ void Theme::loadConfig()
         // Next window
         i++;
     }
+    free( save );
 }
 
 
index a80d1a7f7c89bb7c52ca1c279750da74313f4f22..8385f45ed44b5d4192d7738fb3d1c413936f19d7 100755 (executable)
@@ -97,6 +97,7 @@ bool ThemeLoader::load( const string &fileName )
         // Show the windows
         pNewTheme->getWindowManager().showAll();
     }
+    if( skin_last ) free( skin_last );
 
     return true;
 }
@@ -244,6 +245,7 @@ bool ThemeLoader::findThemeFile( const string &rootDir, string &themeFilePath )
                 // Can we find the theme file in this subdirectory?
                 if( findThemeFile( newURI, themeFilePath ) )
                 {
+                    closedir( pCurrDir );
                     return true;
                 }
             }
@@ -254,6 +256,7 @@ bool ThemeLoader::findThemeFile( const string &rootDir, string &themeFilePath )
                     string( pDirContent->d_name ) )
                 {
                     themeFilePath = newURI;
+                    closedir( pCurrDir );
                     return true;
                 }
             }
@@ -262,6 +265,7 @@ bool ThemeLoader::findThemeFile( const string &rootDir, string &themeFilePath )
         pDirContent = readdir( pCurrDir );
     }
 
+    closedir( pCurrDir );
     return false;
 }
 
index ba27afaed2a439163ead3fb64fbbed27031c13b7..b6c3f2898ad626a36031d2ad4e9346b2d00ecc84 100755 (executable)
@@ -135,6 +135,8 @@ void ThemeRepository::parseDirectory( const string &rDir )
 
         pDirContent = readdir( pDir );
     }
+
+    closedir( pDir );
 }
 
 
index f076c57e3b49cf7cc1ba48d4c9117d4dbd3a3d20..da3d1c81d0a56692d5fd49d536b06017a67e0484 100644 (file)
@@ -34,7 +34,7 @@ Playlist::Playlist( intf_thread_t *pIntf ): VarList( pIntf )
     m_pPlaylist = pIntf->p_sys->p_playlist;
 
     // Try to guess the current charset
-    char *pCharset = (char*)malloc( 100 );
+    char *pCharset;
     vlc_current_charset( &pCharset );
     iconvHandle = vlc_iconv_open( "UTF-8", pCharset );
     msg_Dbg( pIntf, "Using character encoding: %s", pCharset );
index 2ac70ad7ce22be1cc36e1615c1a79f8f1b082017..e5a61b8f7ca506440a8a18e1ae427febb218f3aa 100644 (file)
@@ -211,8 +211,10 @@ X11Display::X11Display( intf_thread_t *pIntf ): SkinObject( pIntf ),
 
         // Set an empty mask for the window
         Region mask = XCreateRegion();
-        XShapeCombineRegion( m_pDisplay, m_mainWindow, ShapeBounding, 0, 0, mask,
-                             ShapeSet );
+        XShapeCombineRegion( m_pDisplay, m_mainWindow, ShapeBounding, 0, 0,
+                             mask, ShapeSet );
+        XDestroyRegion( mask );
+
         // Map the window
         XMapWindow( m_pDisplay, m_mainWindow);