Mercurial > mplayer.hg
diff gui/win32/interface.c @ 33740:2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
Rename guiSetFilename() setdup() and guiSetDF() setddup()
and define them in string.c as functions.
Adjust malloc size to necessary size and check pointer returned
by malloc() to prevent segmentation fault.
author | ib |
---|---|
date | Thu, 07 Jul 2011 10:16:22 +0000 |
parents | 71c29e8ec68f |
children | 6cea6d268f97 |
line wrap: on
line diff
--- a/gui/win32/interface.c Thu Jul 07 09:29:15 2011 +0000 +++ b/gui/win32/interface.c Thu Jul 07 10:16:22 2011 +0000 @@ -96,6 +96,19 @@ return strdup(str); } +static void setdup (char **old, const char *str) +{ + free(*old); + *old = gstrdup(str); +} + +static void setddup (char **old, const char *dir, const char *name) +{ + free(*old); + *old = malloc(strlen(dir) + strlen(name) + 2); + if (*old) sprintf(*old, "%s/%s", dir, name); +} + /** * \brief this actually creates a new list containing only one element... */ @@ -388,9 +401,9 @@ { if(!name) return; if(!dir) - guiSetFilename(guiInfo.Filename, name) + setdup(&guiInfo.Filename, name); else - guiSetDF(guiInfo.Filename, dir, name); + setddup(&guiInfo.Filename, dir, name); guiInfo.StreamType = type; free(guiInfo.AudioFile); @@ -517,7 +530,7 @@ dvd_chapter = guiInfo.DVD.current_chapter; dvd_angle = guiInfo.DVD.current_angle; sprintf(tmp,"dvd://%d", guiInfo.Title); - guiSetFilename(guiInfo.Filename, tmp); + setdup(&guiInfo.Filename, tmp); break; } #endif