diff options
author | Max Kellermann <max@duempel.org> | 2008-10-20 22:18:12 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-10-20 22:18:12 +0200 |
commit | ba96920a52bbd2208aa1f3b284edc864e26198ce (patch) | |
tree | 6750d817780ef892d82e0ce0aecaebd54546799a /src/dirvec.c | |
parent | 99e82a2ef293429e3fcc4f6e5d8e7981b4351c7c (diff) | |
download | mpd-ba96920a52bbd2208aa1f3b284edc864e26198ce.tar.gz mpd-ba96920a52bbd2208aa1f3b284edc864e26198ce.tar.xz mpd-ba96920a52bbd2208aa1f3b284edc864e26198ce.zip |
path: replaced mpd_basename() with g_path_get_basename()
GLib's g_path_get_basename() is much more reliable than
mpd_basename(). The latter could be tricked into an assertion
failure.
Diffstat (limited to 'src/dirvec.c')
-rw-r--r-- | src/dirvec.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/dirvec.c b/src/dirvec.c index 98cb9e7ad..61e5a859a 100644 --- a/src/dirvec.c +++ b/src/dirvec.c @@ -4,6 +4,7 @@ #include "path.h" #include <string.h> +#include <glib.h> static size_t dv_size(struct dirvec *dv) { @@ -25,13 +26,18 @@ void dirvec_sort(struct dirvec *dv) struct directory *dirvec_find(const struct dirvec *dv, const char *path) { + char *basename; int i; - path = mpd_basename(path); + basename = g_path_get_basename(path); for (i = dv->nr; --i >= 0; ) - if (!strcmp(directory_get_name(dv->base[i]), path)) + if (!strcmp(directory_get_name(dv->base[i]), basename)) { + g_free(basename); return dv->base[i]; + } + + g_free(basename); return NULL; } |