aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-11-07 16:17:21 +0100
committerMax Kellermann <max@duempel.org>2008-11-07 16:17:21 +0100
commit521a026319775913bf828aa1c2de5ce5d717811c (patch)
tree11636d22a4fc7a10ab92a8fdda0286d1c66d8699 /src
parent3eca95ac1cb786d1aef59fd141d75661903c039a (diff)
downloadmpd-521a026319775913bf828aa1c2de5ce5d717811c.tar.gz
mpd-521a026319775913bf828aa1c2de5ce5d717811c.tar.xz
mpd-521a026319775913bf828aa1c2de5ce5d717811c.zip
wreadln: return NULL instead of empty string
No wreadln() caller cares about an empty string. Simplify the callers by returning NULL instead of an allocated empty string. This fixes several memory leaks.
Diffstat (limited to '')
-rw-r--r--src/screen_play.c4
-rw-r--r--src/screen_search.c5
-rw-r--r--src/screen_utils.c2
-rw-r--r--src/wreadln.c3
4 files changed, 6 insertions, 8 deletions
diff --git a/src/screen_play.c b/src/screen_play.c
index 8855ffc78..4c21a1769 100644
--- a/src/screen_play.c
+++ b/src/screen_play.c
@@ -201,7 +201,7 @@ playlist_save(mpdclient_t *c, char *name, char *defaultname)
#endif
filename=g_strdup(name);
- if (filename == NULL || filename[0] == '\0')
+ if (filename == NULL)
return -1;
/* send save command to mpd */
@@ -343,7 +343,7 @@ handle_add_to_playlist(mpdclient_t *c)
#endif
/* add the path to the playlist */
- if (path && path[0]) {
+ if (path != NULL) {
char *path_utf8 = locale_to_utf8(path);
mpdclient_cmd_add_path(c, path_utf8);
g_free(path_utf8);
diff --git a/src/screen_search.c b/src/screen_search.c
index 7cb04e85f..48afb4e51 100644
--- a/src/screen_search.c
+++ b/src/screen_search.c
@@ -313,11 +313,6 @@ search_new(mpdclient_t *c)
&search_history,
NULL);
- if (pattern && strcmp(pattern,"") == 0) {
- g_free(pattern);
- pattern=NULL;
- }
-
if (pattern == NULL) {
list_window_reset(browser.lw);
return;
diff --git a/src/screen_utils.c b/src/screen_utils.c
index e44d8eb67..308d049f4 100644
--- a/src/screen_utils.c
+++ b/src/screen_utils.c
@@ -177,7 +177,7 @@ screen_find(list_window_t *lw,
&screen.find_history,
NULL);
- if (!screen.findbuf || !screen.findbuf[0])
+ if (screen.findbuf == NULL)
return 1;
if (reversed)
diff --git a/src/wreadln.c b/src/wreadln.c
index df5b55e8c..a382fcecc 100644
--- a/src/wreadln.c
+++ b/src/wreadln.c
@@ -603,6 +603,9 @@ _wreadln(WINDOW *w,
}
}
+ if (wr.line[0] == 0)
+ return NULL;
+
return g_strdup(wr.line);
}