aboutsummaryrefslogtreecommitdiffstats
path: root/src/update.c
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2008-10-11 20:41:55 -0700
committerEric Wong <normalperson@yhbt.net>2008-10-12 05:27:32 -0700
commite28fb29349a811f0f306e9ac4bedf6013417d043 (patch)
treec28a33e1361a4a507dc2c401f4cce26eda7cd9aa /src/update.c
parentc6ee14dca5d7336dad20a6057aa2a8006d4447b8 (diff)
downloadmpd-e28fb29349a811f0f306e9ac4bedf6013417d043.tar.gz
mpd-e28fb29349a811f0f306e9ac4bedf6013417d043.tar.xz
mpd-e28fb29349a811f0f306e9ac4bedf6013417d043.zip
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</highlander>.
Diffstat (limited to 'src/update.c')
-rw-r--r--src/update.c10
1 files changed, 4 insertions, 6 deletions
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)