From: RĂ©mi Denis-Courmont Date: Tue, 7 Mar 2006 20:06:53 +0000 (+0000) Subject: - Undo [14667] X-Git-Tag: 0.9.0-test0~11998 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=ed0c577349232a69aceb2ff6e4f2f8c04f3fae42;p=vlc - Undo [14667] * fix memleak * remove unused variable (psz_local always NULL...) * remove free(NULL) * remove expansion-unsafe wxDnDLocaleFree() macro variant - Actually fix [14633] flawed logic --- diff --git a/modules/gui/wxwidgets/dialogs/playlist.cpp b/modules/gui/wxwidgets/dialogs/playlist.cpp index 612c3e7d70..c4102e8416 100644 --- a/modules/gui/wxwidgets/dialogs/playlist.cpp +++ b/modules/gui/wxwidgets/dialogs/playlist.cpp @@ -1292,13 +1292,12 @@ bool PlaylistFileDropTarget::OnDropFiles( wxCoord x, wxCoord y, /* Put the items in the playlist node */ for( size_t i = 0; i < filenames.GetCount(); i++ ) { - char *psz_local = NULL; - const char *psz_utf8 = wxDnDFromLocale( filenames[i], psz_local ); + const char *psz_utf8 = wxDnDFromLocale( filenames[i] ); playlist_item_t *p_item = playlist_ItemNew( p->p_playlist, psz_utf8, psz_utf8 ); playlist_NodeAddItem( p->p_playlist, p_item, p->i_current_view, p_dest, PLAYLIST_PREPARSE, i_pos ); - wxDnDLocaleFree( psz_utf8, psz_local ); + wxDnDLocaleFree( psz_utf8 ); } /* FIXME: having this Rebuild() is dirty */ diff --git a/modules/gui/wxwidgets/interface.cpp b/modules/gui/wxwidgets/interface.cpp index 1f43383784..1237702c27 100644 --- a/modules/gui/wxwidgets/interface.cpp +++ b/modules/gui/wxwidgets/interface.cpp @@ -1261,14 +1261,13 @@ bool DragAndDrop::OnDropFiles( wxCoord, wxCoord, for( size_t i = 0; i < filenames.GetCount(); i++ ) { - char *psz_local = NULL; - const char *psz_utf8 = wxDnDFromLocale( filenames[i], psz_local ); + char *psz_utf8 = wxDnDFromLocale( filenames[i] ); playlist_Add( p_playlist, psz_utf8, psz_utf8, PLAYLIST_APPEND | ((i | b_enqueue) ? 0 : PLAYLIST_GO), PLAYLIST_END ); - wxDnDLocaleFree( psz_utf8, psz_local ); + wxDnDLocaleFree( psz_utf8 ); } vlc_object_release( p_playlist ); diff --git a/modules/gui/wxwidgets/wxwidgets.hpp b/modules/gui/wxwidgets/wxwidgets.hpp index d35e644553..bd69b13ace 100644 --- a/modules/gui/wxwidgets/wxwidgets.hpp +++ b/modules/gui/wxwidgets/wxwidgets.hpp @@ -98,7 +98,7 @@ DECLARE_LOCAL_EVENT_TYPE( wxEVT_INTF, 1 ); /* From Locale functions to use for File Drop targets ... go figure */ #ifdef wxUSE_UNICODE -inline const char *wxDnDFromLocale( const wxChar *stupid, char *psz_local ) +static inline char *wxDnDFromLocale( const wxChar *stupid ) { /* * FIXME: this is yet another awful and ugly bug-to-bug work-around @@ -120,21 +120,19 @@ inline const char *wxDnDFromLocale( const wxChar *stupid, char *psz_local ) for (braindead = stupid; *braindead; braindead++); size_t i = (braindead - stupid); - psz_local = (char *)malloc( i + 1 ); + char *psz_local = (char *)malloc( i + 1 ); do psz_local[i] = (char)stupid[i]; while (i--); - const char *psz_utf8 = FromLocale( psz_local ); + char *psz_utf8 = FromLocaleDup( psz_local ); + free( psz_local ); return psz_utf8; } +# define wxDnDLocaleFree( string ) free( string ) #else -# define wxDnDFromLocale( string, a ) wxFromLocale( string ) -#endif -#ifdef wxUSE_UNICODE -# define wxDnDLocaleFree( string, a ) LocaleFree( string ); free( a ) -#else -# define wxDnDLocaleFree( string, a ) wxLocaleFree( string ) +# define wxDnDFromLocale( string ) wxFromLocale( string ) +# define wxDnDLocaleFree( string ) wxLocaleFree( string ) #endif #define WRAPCOUNT 80