diff options
author | Eric Wong <normalperson@yhbt.net> | 2008-10-11 19:49:14 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2008-10-11 23:34:36 -0700 |
commit | 6e2b0ca9edaed200f250ef487701ad161aa4a168 (patch) | |
tree | fda140c473d960546bc8123be4b85e72fbe9b1b8 /src/directory.c | |
parent | e71207440ebdf492e00fd5ac73b0833c82366ac6 (diff) | |
download | mpd-6e2b0ca9edaed200f250ef487701ad161aa4a168.tar.gz mpd-6e2b0ca9edaed200f250ef487701ad161aa4a168.tar.xz mpd-6e2b0ca9edaed200f250ef487701ad161aa4a168.zip |
directory: don't use identical struct and variable names
Duplicated tokens in close proximity takes too long for my head
to parse; and "dir" is an easy and common abbreviation for
"directory".
Diffstat (limited to '')
-rw-r--r-- | src/directory.c | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/src/directory.c b/src/directory.c index 273515b91..b90b477fd 100644 --- a/src/directory.c +++ b/src/directory.c @@ -25,32 +25,32 @@ struct directory * directory_new(const char *dirname, struct directory * parent) { - struct directory *directory; + struct directory *dir; assert(dirname != NULL); assert((*dirname == 0) == (parent == NULL)); - directory = xcalloc(1, sizeof(*directory)); - directory->path = xstrdup(dirname); - directory->parent = parent; + dir = xcalloc(1, sizeof(struct directory)); + dir->path = xstrdup(dirname); + dir->parent = parent; - return directory; + return dir; } -void directory_free(struct directory * directory) +void directory_free(struct directory *dir) { - dirvec_destroy(&directory->children); - songvec_destroy(&directory->songs); - free(directory->path); - free(directory); + dirvec_destroy(&dir->children); + songvec_destroy(&dir->songs); + free(dir->path); + free(dir); /* this resets last dir returned */ /*directory_get_path(NULL); */ } -void directory_prune_empty(struct directory * directory) +void directory_prune_empty(struct directory *dir) { int i; - struct dirvec *dv = &directory->children; + struct dirvec *dv = &dir->children; for (i = dv->nr; --i >= 0; ) { directory_prune_empty(dv->base[i]); @@ -62,9 +62,9 @@ void directory_prune_empty(struct directory * directory) } struct directory * -directory_get_subdir(struct directory * directory, const char *name) +directory_get_subdir(struct directory *dir, const char *name) { - struct directory *cur = directory; + struct directory *cur = dir; struct directory *found = NULL; char *duplicated; char *locate; @@ -72,7 +72,7 @@ directory_get_subdir(struct directory * directory, const char *name) assert(name != NULL); if (isRootDirectory(name)) - return directory; + return dir; duplicated = xstrdup(name); locate = strchr(duplicated, '/'); @@ -94,33 +94,33 @@ directory_get_subdir(struct directory * directory, const char *name) return found; } -void directory_sort(struct directory * directory) +void directory_sort(struct directory *dir) { int i; - struct dirvec *dv = &directory->children; + struct dirvec *dv = &dir->children; dirvec_sort(dv); - songvec_sort(&directory->songs); + songvec_sort(&dir->songs); for (i = dv->nr; --i >= 0; ) directory_sort(dv->base[i]); } int -directory_walk(struct directory * directory, +directory_walk(struct directory *dir, int (*forEachSong) (struct mpd_song *, void *), int (*forEachDir) (struct directory *, void *), void *data) { - struct dirvec *dv = &directory->children; + struct dirvec *dv = &dir->children; int err = 0; size_t j; - if (forEachDir && (err = forEachDir(directory, data)) < 0) + if (forEachDir && (err = forEachDir(dir, data)) < 0) return err; if (forEachSong) { - err = songvec_for_each(&directory->songs, forEachSong, data); + err = songvec_for_each(&dir->songs, forEachSong, data); if (err < 0) return err; } |