From: resver Date: Thu, 10 Jan 2013 17:09:43 +0000 (+0000) Subject: Removed duplicate code in reset_cache(): now it uses tree_detach() to remove children... X-Git-Url: http://git.osdn.net/view?p=android-x86%2Fexternal-exfat.git;a=commitdiff_plain;h=882c51c5b5fc73152f31f69949a3749a6847409a Removed duplicate code in reset_cache(): now it uses tree_detach() to remove children from the list and the whole tree is consistent at any iteration. git-svn-id: http://exfat.googlecode.com/svn/trunk@328 60bc1c72-a15a-11de-b98f-4500b42dc123 --- diff --git a/libexfat/node.c b/libexfat/node.c index b680208..2eada9a 100644 --- a/libexfat/node.c +++ b/libexfat/node.c @@ -483,15 +483,14 @@ static void tree_detach(struct exfat_node* node) static void reset_cache(struct exfat* ef, struct exfat_node* node) { - struct exfat_node* child; - struct exfat_node* next; - - for (child = node->child; child; child = next) + while (node->child) { - reset_cache(ef, child); - next = child->next; - free(child); + struct exfat_node* p = node->child; + reset_cache(ef, p); + tree_detach(p); + free(p); } + node->flags &= ~EXFAT_ATTRIB_CACHED; if (node->references != 0) { char buffer[EXFAT_NAME_MAX + 1]; @@ -501,8 +500,6 @@ static void reset_cache(struct exfat* ef, struct exfat_node* node) } while (node->references) exfat_put_node(ef, node); - node->child = NULL; - node->flags &= ~EXFAT_ATTRIB_CACHED; } void exfat_reset_cache(struct exfat* ef)