From e28fb29349a811f0f306e9ac4bedf6013417d043 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 11 Oct 2008 20:41:55 -0700 Subject: directory: make music_root global and avoid runtime initialization mpd can't function without music_root; so don't bother allocating it on the heap nor checking to see if it's initialized. Don't allow directory_new() to create a directory w/o a parent or with an empty path, either: root is root and there can be only one. --- src/update.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/update.c') diff --git a/src/update.c b/src/update.c index ca3640b73..3f6fa15ed 100644 --- a/src/update.c +++ b/src/update.c @@ -317,10 +317,9 @@ directory_make_child_checked(struct directory *parent, const char *path) return dir; } -static struct directory * -addParentPathToDB(const char *utf8path) +static struct directory * addParentPathToDB(const char *utf8path) { - struct directory *dir = db_get_root(); + struct directory *dir = &music_root; char *duplicated = xstrdup(utf8path); char *slash = duplicated; @@ -354,11 +353,10 @@ static void * update_task(void *_path) updatePath((char *)_path); free(_path); } else { - struct directory *dir = db_get_root(); struct stat st; - if (myStat(directory_get_path(dir), &st) == 0) - updateDirectory(dir, &st); + if (myStat(directory_get_path(&music_root), &st) == 0) + updateDirectory(&music_root, &st); } if (modified) -- cgit v1.2.3