diff options
author | Max Kellermann <max@duempel.org> | 2008-10-08 11:06:44 +0200 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2008-10-11 19:21:48 -0700 |
commit | f8e2879c37b9ee5953e71456ba777363f7dc30fc (patch) | |
tree | 756f2eb8597e267b805e90aad8d685e495476507 | |
parent | 81bdc3f625ecce1eca87009caf89e98abd405f51 (diff) | |
download | mpd-f8e2879c37b9ee5953e71456ba777363f7dc30fc.tar.gz mpd-f8e2879c37b9ee5953e71456ba777363f7dc30fc.tar.xz mpd-f8e2879c37b9ee5953e71456ba777363f7dc30fc.zip |
directory: converted isRootDirectory() to an inline function
The function isRootDirectory() is tiny and can be converted to an
inline function. Don't allow name==NULL.
-rw-r--r-- | src/directory.c | 10 | ||||
-rw-r--r-- | src/directory.h | 6 |
2 files changed, 10 insertions, 6 deletions
diff --git a/src/directory.c b/src/directory.c index f76dd9c95..25a6bcec8 100644 --- a/src/directory.c +++ b/src/directory.c @@ -105,11 +105,6 @@ struct directory * directory_get_root(void) return music_root; } -int isRootDirectory(const char *name) -{ - return (!name || name[0] == '\0' || !strcmp(name, "/")); -} - static struct directory * getSubDirectory(struct directory * directory, const char *name) { @@ -118,6 +113,8 @@ getSubDirectory(struct directory * directory, const char *name) char *duplicated; char *locate; + assert(name != NULL); + if (isRootDirectory(name)) return directory; @@ -143,6 +140,9 @@ getSubDirectory(struct directory * directory, const char *name) struct directory * getDirectory(const char *name) { + if (name == NULL) + return music_root; + return getSubDirectory(music_root, name); } diff --git a/src/directory.h b/src/directory.h index 72de511e7..127da678c 100644 --- a/src/directory.h +++ b/src/directory.h @@ -41,7 +41,11 @@ void directory_init(void); void directory_finish(void); -int isRootDirectory(const char *name); +static inline int isRootDirectory(const char *name) +{ + /* TODO: verify and remove !name check */ + return (!name || *name == '\0' || !strcmp(name, "/")); +} struct directory * directory_get_root(void); |