diff --git a/src/backgrounds.c b/src/backgrounds.c index 3ba6f9c4..d8c690a5 100644 --- a/src/backgrounds.c +++ b/src/backgrounds.c @@ -1517,15 +1517,13 @@ BG_GetValues(void) static void BG_DialogSetFileName(DItem * di) { - char *stmp = NULL; + const char *stmp; char s[1024]; - if (BackgroundGetBgFile(tmp_bg)) - stmp = fullfileof(BackgroundGetBgFile(tmp_bg)); + stmp = fullfileof(BackgroundGetBgFile(tmp_bg)); Esnprintf(s, sizeof(s), _("Background definition information:\nName: %s\nFile: %s\n"), BackgroundGetName(tmp_bg), (stmp) ? stmp : _("-NONE-")); - Efree(stmp); DialogItemSetText(di, s); } diff --git a/src/file.c b/src/file.c index 50c2fe8a..b09e74c6 100644 --- a/src/file.c +++ b/src/file.c @@ -267,13 +267,15 @@ fileof(const char *path) return Estrndup(s1, s2 - s1); } -char * +const char * fullfileof(const char *path) { const char *s; + if (!path) + return NULL; s = strrchr(path, '/'); - return Estrdup((s) ? s + 1 : path); + return (s) ? s + 1 : path; } char * diff --git a/src/file.h b/src/file.h index 342f3509..6c1a0e8b 100644 --- a/src/file.h +++ b/src/file.h @@ -56,7 +56,7 @@ int filedev(const char *s); int isabspath(const char *s); const char *fileext(const char *s); char *fileof(const char *s); -char *fullfileof(const char *s); +const char *fullfileof(const char *s); char *path_test(const char *file, unsigned int test); int path_canexec(const char *file); diff --git a/src/menus-misc.c b/src/menus-misc.c index f66fcbde..affea17f 100644 --- a/src/menus-misc.c +++ b/src/menus-misc.c @@ -538,7 +538,8 @@ MenuLoadFromThemes(Menu * m) { char **lst; int i, num; - char ss[4096], *s; + char ss[4096]; + const char *s; MenuItem *mi; if (MenuGetTimestamp(m)) @@ -551,7 +552,6 @@ MenuLoadFromThemes(Menu * m) s = fullfileof(lst[i]); Esnprintf(ss, sizeof(ss), "theme use %s", s); mi = MenuItemCreate(s, NULL, ss, NULL); - Efree(s); MenuAddItem(m, mi); } if (lst) diff --git a/src/theme.c b/src/theme.c index 2b439bce..a6638a7a 100644 --- a/src/theme.c +++ b/src/theme.c @@ -425,7 +425,7 @@ ThemePathFind(void) } Efree(Conf.theme.name); - Conf.theme.name = (theme) ? fullfileof(theme) : NULL; + Conf.theme.name = Estrdup(fullfileof(theme)); Efree(Mode.theme.path); Mode.theme.path = (theme) ? theme : Estrdup("-");