summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3eca95a)
raw | patch | inline | side by side (parent: 3eca95a)
author | Max Kellermann <max@duempel.org> | |
Fri, 7 Nov 2008 15:17:21 +0000 (16:17 +0100) | ||
committer | Max Kellermann <max@duempel.org> | |
Fri, 7 Nov 2008 15:17:21 +0000 (16:17 +0100) |
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.
by returning NULL instead of an allocated empty string. This fixes
several memory leaks.
src/screen_play.c | patch | blob | history | |
src/screen_search.c | patch | blob | history | |
src/screen_utils.c | patch | blob | history | |
src/wreadln.c | patch | blob | history |
diff --git a/src/screen_play.c b/src/screen_play.c
index 8855ffc7816e93912f932e253d3ee160a4be9e1c..4c21a17697b8b657ab6299fdb7c00d9c641bcec5 100644 (file)
--- a/src/screen_play.c
+++ b/src/screen_play.c
#endif
filename=g_strdup(name);
- if (filename == NULL || filename[0] == '\0')
+ if (filename == NULL)
return -1;
/* send save command to mpd */
#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 7cb04e85fb6ea29634874dbae1de902f40151ffb..48afb4e51804a0991a4f01c5a836e5f011ced575 100644 (file)
--- a/src/screen_search.c
+++ b/src/screen_search.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 e44d8eb67cc03e442ef803af0f1da86a15eca39b..308d049f4802ab0bdda2576083a0c9110255b579 100644 (file)
--- a/src/screen_utils.c
+++ b/src/screen_utils.c
&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 df5b55e8c97a9d7ae2477a8363de70fdaab9f1f6..a382fcecc2d7cbc1ddb4410fcd56c52c936b4134 100644 (file)
--- a/src/wreadln.c
+++ b/src/wreadln.c
}
}
+ if (wr.line[0] == 0)
+ return NULL;
+
return g_strdup(wr.line);
}