fix memory leak as Dimitri suggested
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19658 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -214,34 +214,43 @@ void wxPathList::Add (const wxString& path)
|
|||||||
// Add paths e.g. from the PATH environment variable
|
// Add paths e.g. from the PATH environment variable
|
||||||
void wxPathList::AddEnvList (const wxString& envVariable)
|
void wxPathList::AddEnvList (const wxString& envVariable)
|
||||||
{
|
{
|
||||||
static const wxChar PATH_TOKS[] =
|
static const wxChar PATH_TOKS[] =
|
||||||
#ifdef __WINDOWS__
|
#ifdef __WINDOWS__
|
||||||
wxT(" ;"); // Don't seperate with colon in DOS (used for drive)
|
/*
|
||||||
|
The space has been removed from the tokenizers, otherwise a
|
||||||
|
path such as "C:\Program Files" would be split into 2 paths:
|
||||||
|
"C:\Program" and "Files"
|
||||||
|
*/
|
||||||
|
// wxT(" ;"); // Don't seperate with colon in DOS (used for drive)
|
||||||
|
wxT(";"); // Don't seperate with colon in DOS (used for drive)
|
||||||
#else
|
#else
|
||||||
wxT(" :;");
|
wxT(" :;");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxChar *val = wxGetenv (WXSTRINGCAST envVariable);
|
wxChar *val = wxGetenv (WXSTRINGCAST envVariable);
|
||||||
if (val && *val)
|
if (val && *val)
|
||||||
{
|
{
|
||||||
wxChar *s = copystring (val);
|
wxChar *s = copystring (val);
|
||||||
wxChar *save_ptr, *token = wxStrtok (s, PATH_TOKS, &save_ptr);
|
wxChar *save_ptr, *token = wxStrtok (s, PATH_TOKS, &save_ptr);
|
||||||
|
|
||||||
if (token)
|
if (token)
|
||||||
{
|
{
|
||||||
Add (copystring (token));
|
Add(token);
|
||||||
while (token)
|
while (token)
|
||||||
{
|
{
|
||||||
if ((token = wxStrtok ((wxChar *) NULL, PATH_TOKS, &save_ptr)) != NULL)
|
if ( (token = wxStrtok ((wxChar *) NULL, PATH_TOKS, &save_ptr))
|
||||||
Add (wxString(token));
|
!= NULL )
|
||||||
}
|
{
|
||||||
}
|
Add(token);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// suppress warning about unused variable save_ptr when wxStrtok() is a
|
// suppress warning about unused variable save_ptr when wxStrtok() is a
|
||||||
// macro which throws away its third argument
|
// macro which throws away its third argument
|
||||||
save_ptr = token;
|
save_ptr = token;
|
||||||
|
|
||||||
delete [] s;
|
delete [] s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user