aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-10-09 15:48:39 +0200
committerEric Wong <normalperson@yhbt.net>2008-10-11 19:21:50 -0700
commit08ac9c4b05d51f79733b6ad27b7a79240c92fb03 (patch)
tree071b5ead4e58031f3662b2793a217125b04acda7
parentf2fd7be1d7b80da32611c57360e71fb777b95c7d (diff)
downloadmpd-08ac9c4b05d51f79733b6ad27b7a79240c92fb03.tar.gz
mpd-08ac9c4b05d51f79733b6ad27b7a79240c92fb03.tar.xz
mpd-08ac9c4b05d51f79733b6ad27b7a79240c92fb03.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.
-rw-r--r--src/update.c26
1 files changed, 3 insertions, 23 deletions
diff --git a/src/update.c b/src/update.c
index 1415852e0..c2f611e9e 100644
--- a/src/update.c
+++ b/src/update.c
@@ -338,15 +338,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 (1) {
- if ((slash = strchr(slash, '/')))
- *slash = 0;
+ while ((slash = strchr(slash, '/'))) {
+ *slash = 0;
directory = directory_make_child_checked(directory, duplicated);
if (!directory || !slash)
@@ -359,25 +358,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;