From d99f074eb73d5228528961a78c13419c2c4c26ae Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 24 Jan 2012 18:20:58 +0100 Subject: directory: replace dirvec with doubly linked list Random access is not needed, and a linked list is easier to manage: we don't need to (re-)allocate the pointer array. --- src/directory_save.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src/directory_save.c') diff --git a/src/directory_save.c b/src/directory_save.c index 975e2e745..087c99fe4 100644 --- a/src/directory_save.c +++ b/src/directory_save.c @@ -44,8 +44,6 @@ directory_quark(void) void directory_save(FILE *fp, const struct directory *directory) { - size_t i; - if (!directory_is_root(directory)) { fprintf(fp, DIRECTORY_MTIME "%lu\n", (unsigned long)directory->mtime); @@ -54,9 +52,8 @@ directory_save(FILE *fp, const struct directory *directory) directory_get_path(directory)); } - const struct dirvec *children = &directory->children; - for (i = 0; i < children->nr; ++i) { - const struct directory *cur = children->base[i]; + struct directory *cur; + directory_for_each_child(cur, directory) { char *base = g_path_get_basename(cur->path); fprintf(fp, DIRECTORY_DIR "%s\n", base); -- cgit v1.2.3