aboutsummaryrefslogtreecommitdiffstats
path: root/src/update.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-10-09 15:48:39 +0200
committerMax Kellermann <max@duempel.org>2008-10-09 15:48:39 +0200
commita79bd723e211c967800f523ecf3b3f886a906d97 (patch)
treec9f83c53556ef3073a9c5d546b01eff342cf2db5 /src/update.c
parent4990f04ac09a68db70f8114ebb9d40e684db5d00 (diff)
downloadmpd-a79bd723e211c967800f523ecf3b3f886a906d97.tar.gz
mpd-a79bd723e211c967800f523ecf3b3f886a906d97.tar.xz
mpd-a79bd723e211c967800f523ecf3b3f886a906d97.zip
update: merged addDirectoryPathToDB() into addParentPathToDB()
The algorithm in addDirectoryPathToDB() can be simplified further if it is combined with the function addParentPathToDB(). Since there is no other caller of addDirectoryPathToDB(), we can do that. This saves another large stack buffer.
Diffstat (limited to 'src/update.c')
-rw-r--r--src/update.c28
1 files changed, 3 insertions, 25 deletions
diff --git a/src/update.c b/src/update.c
index d8bbc02d0..b9bc3ffd5 100644
--- a/src/update.c
+++ b/src/update.c
@@ -352,16 +352,14 @@ directory_make_child_checked(struct directory *parent, const char *path)
}
static struct directory *
-addDirectoryPathToDB(const char *utf8path)
+addParentPathToDB(const char *utf8path)
{
struct directory *directory = db_get_root();
char *duplicated = xstrdup(utf8path);
char *slash = duplicated;
- while (true) {
- slash = strchr(slash, '/');
- if (slash != NULL)
- *slash = 0;
+ while ((slash = strchr(slash, '/')) != NULL) {
+ *slash = 0;
directory = directory_make_child_checked(directory,
duplicated);
@@ -375,26 +373,6 @@ addDirectoryPathToDB(const char *utf8path)
return directory;
}
-static struct directory *
-addParentPathToDB(const char *utf8path)
-{
- char *parent;
- char path_max_tmp[MPD_PATH_MAX];
- struct directory *parentDirectory;
-
- parent = parent_path(path_max_tmp, utf8path);
-
- if (strlen(parent) == 0)
- parentDirectory = db_get_root();
- else
- parentDirectory = addDirectoryPathToDB(parent);
-
- if (!parentDirectory)
- return NULL;
-
- return (struct directory *) parentDirectory;
-}
-
static enum update_return updatePath(const char *utf8path)
{
struct directory *directory;