From 227b17f251ad2a4cb978965d6fe48205ac0b6219 Mon Sep 17 00:00:00 2001 From: Vreixo Formoso Date: Sun, 23 Dec 2007 17:41:21 +0100 Subject: [PATCH] Store a pointer to the real parent in reparent dirs. --- src/ecma119_tree.c | 3 +++ src/ecma119_tree.h | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/src/ecma119_tree.c b/src/ecma119_tree.c index 7f1969a..e4d1370 100644 --- a/src/ecma119_tree.c +++ b/src/ecma119_tree.c @@ -651,6 +651,9 @@ int reparent(Ecma119Node *child, Ecma119Node *parent) return ISO_ERROR; } + /* keep track of the real parent */ + child->info.dir.real_parent = child->parent; + /* add the child to its new parent */ child->parent = parent; parent->info.dir.nchildren++; diff --git a/src/ecma119_tree.h b/src/ecma119_tree.h index d609414..12a55ba 100644 --- a/src/ecma119_tree.h +++ b/src/ecma119_tree.h @@ -29,6 +29,11 @@ struct ecma119_dir_info { size_t nchildren; Ecma119Node **children; + + /** + * Real parent if the dir has been reallocated. NULL otherwise. + */ + Ecma119Node *real_parent; }; /** @@ -51,6 +56,8 @@ struct ecma119_node enum ecma119_node_type type; union { IsoFileSrc *file; + // TODO this wastes too much memory, as dirs have much more + // atts than other kind of files. Replace with a pointer. struct ecma119_dir_info dir; /** this field points to the relocated directory. */ Ecma119Node *real_me;