[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r19556 - gnunet-gtk/src/fs
From: |
gnunet |
Subject: |
[GNUnet-SVN] r19556 - gnunet-gtk/src/fs |
Date: |
Tue, 31 Jan 2012 00:31:39 +0100 |
Author: grothoff
Date: 2012-01-31 00:31:39 +0100 (Tue, 31 Jan 2012)
New Revision: 19556
Modified:
gnunet-gtk/src/fs/gnunet-fs-gtk-main_window_file_publish.c
Log:
-eliminating tree traversal travesty
Modified: gnunet-gtk/src/fs/gnunet-fs-gtk-main_window_file_publish.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk-main_window_file_publish.c 2012-01-30
23:23:28 UTC (rev 19555)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk-main_window_file_publish.c 2012-01-30
23:31:39 UTC (rev 19556)
@@ -867,67 +867,31 @@
}
-/* Used to avoid recursion */
-// FIXME: we should probably use recursion instead ;-).
-struct AddShareItemsStack
-{
- struct AddShareItemsStack *parent;
- GtkTreeIter last_added;
-};
-
-
/**
* Traverse the share tree and add it to the tree store
*
*/
static void
add_share_items_to_treestore (struct AddDirClientContext *adcc,
- struct GNUNET_FS_ShareTreeItem *toplevel)
+ struct GNUNET_FS_ShareTreeItem *toplevel,
+ GtkTreeIter *parent_iter)
{
struct MainPublishingDialogContext *ctx = adcc->ctx;
GtkTreeStore *ts = GTK_TREE_STORE (ctx->file_info_treemodel);
- GtkTreeIter *parent_iter;
GtkTreeIter *sibling_iter;
- struct GNUNET_FS_ShareTreeItem *item, *next;
- struct AddShareItemsStack *stack;
+ GtkTreeIter last_added;
+ struct GNUNET_FS_ShareTreeItem *item;
- stack = GNUNET_malloc (sizeof (struct AddShareItemsStack));
- parent_iter = NULL;
sibling_iter = NULL;
- for (item = toplevel; item != NULL; item = next)
+ for (item = toplevel; item != NULL; item = item->next)
{
- add_item (adcc, ts, item, parent_iter, sibling_iter, &stack->last_added);
- sibling_iter = &stack->last_added;
- if (item->is_directory)
- {
- if (item->children_head != NULL)
- {
- struct AddShareItemsStack *child = GNUNET_malloc (sizeof (struct
AddShareItemsStack));
- child->parent = stack;
- sibling_iter = NULL;
- parent_iter = &stack->last_added;
- stack = child;
- next = item->children_head;
- continue;
- }
- }
- while ((next = item->next) == NULL)
- {
- if (item->parent != NULL)
- {
- next = item->parent;
- struct AddShareItemsStack *child;
- sibling_iter = &stack->parent->last_added;
- parent_iter = stack->parent->parent != NULL ?
&stack->parent->parent->last_added : NULL;
- child = stack;
- stack = stack->parent;
- item = next;
- }
- else
- break;
- }
+ add_item (adcc, ts, item, parent_iter, sibling_iter, &last_added);
+ sibling_iter = &last_added;
+ if (item->is_directory)
+ add_share_items_to_treestore (adcc,
+ item,
+ sibling_iter);
}
- GNUNET_free (stack);
}
@@ -1019,7 +983,8 @@
adcc->ds = NULL;
GNUNET_FS_share_tree_trim (adcc->directory_scan_result);
add_share_items_to_treestore (adcc,
- adcc->directory_scan_result);
+ adcc->directory_scan_result,
+ NULL);
GNUNET_FS_share_tree_free (adcc->directory_scan_result);
adcc->directory_scan_result = NULL;
update_selectivity (adcc->ctx);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r19556 - gnunet-gtk/src/fs,
gnunet <=