+Sun Nov 6 17:06:52 2005 Soeren Sandmann <sandmann@redhat.com>
+
+ * profile.c (add_trace_to_tree): Turn this function into a
+ StackFunction.
+
+ * stackstash.c (stack_node_foreach_trace): Make this function take
+ a StackFunction, and reimplement with do_callback().
+
Sat Nov 5 18:06:40 2005 Soeren Sandmann <sandmann@redhat.com>
* profile.c (profile_create_descendants): Use callbacks from
typedef struct Node Node;
-static void
-update()
-{
-#if 0
- while (g_main_pending())
- g_main_iteration (FALSE);
-#endif
-}
-
struct Profile
{
StackStash * stash;
}
static void
-add_trace_to_tree (GSList *trace, gpointer data)
+add_trace_to_tree (GSList *trace, gint size, gpointer data)
{
GSList *list;
GPtrArray *nodes_to_unmark = g_ptr_array_new ();
ProfileDescendant *parent = NULL;
int i, len;
ProfileDescendant **tree = data;
- guint size = ((StackNode *)trace->data)->size;
trace = g_slist_reverse (g_slist_copy (trace));
for (list = trace; list != NULL; list = list->next)
{
- StackNode *node = list->data;
+ gpointer address = list->data;
ProfileDescendant *match = NULL;
- update();
-
for (match = *tree; match != NULL; match = match->siblings)
{
- if (match->name == node->address)
+ if (match->name == address)
break;
}
seen_tree_node = NULL;
for (n = parent; n != NULL; n = n->parent)
{
- if (n->name == node->address)
+ if (n->name == address)
seen_tree_node = n;
}
{
match = g_new (ProfileDescendant, 1);
- match->name = node->address;
+ match->name = address;
match->non_recursion = 0;
match->self = 0;
match->children = NULL;
/* FIXME: we will probably want to do this lazily,
* and more efficiently (only walk the tree once).
*/
-
for (n = node->parent; n != NULL; n = n->parent)
{
if (n->address == node->address)
static void
do_callback (StackNode *node,
- GSList *trace,
- StackFunction stack_func,
+ const GSList *trace,
+ StackFunction func,
gpointer data)
{
GSList link;
-
+
if (!node)
return;
- link.next = trace;
+ link.next = (GSList *)trace;
link.data = node->address;
-
- do_callback (node->siblings, trace, stack_func, data);
- do_callback (node->children, &link, stack_func, data);
if (node->size)
- stack_func (&link, node->size, data);
+ func (&link, node->size, data);
+
+ do_callback (node->children, &link, func, data);
+ do_callback (node->siblings, trace, func, data);
}
void
do_callback (stash->root, NULL, stack_func, data);
}
-static void
-do_node_callback (StackNode *node, const GSList *trace,
- StackTraceFunction func,
- gpointer data)
-{
- GSList link;
-
- if (!node)
- return;
-
- link.next = (GSList *)trace;
- link.data = node;
-
- if (node->size)
- func (&link, data);
-
- do_node_callback (node->children, &link, func, data);
- do_node_callback (node->siblings, trace, func, data);
-}
-
void
-stack_node_foreach_trace (StackNode *node,
- StackTraceFunction func,
- gpointer data)
+stack_node_foreach_trace (StackNode *node,
+ StackFunction func,
+ gpointer data)
{
GSList link;
link.next = NULL;
- link.data = node;
+ link.data = node->address;
if (node->size)
- func (&link, data);
+ func (&link, node->size, data);
- do_node_callback (node->children, &link, func, data);
+ do_callback (node->children, &link, func, data);
}
static void
void stack_stash_foreach (StackStash *stash,
StackFunction stack_func,
gpointer data);
+void stack_node_foreach_trace (StackNode *node,
+ StackFunction stack_func,
+ gpointer data);
StackNode *stack_stash_find_node (StackStash *stash,
gpointer address);
/* FIXME: should probably return a list */
void stack_node_list_leaves (StackNode *node,
GList **leaves);
-typedef void (* StackTraceFunction) (GSList *trace, gpointer data);
-void stack_node_foreach_trace (StackNode *node,
- StackTraceFunction func,
- gpointer data);
-
typedef void (* StackNodeFunc) (StackNode *node,
gpointer data);
void stack_stash_foreach_by_address (StackStash *stash,
set_busy (app->main_window, TRUE);
- gdk_window_process_all_updates ();
+ gdk_window_process_all_updates (); /* Display updated selection */
fill_descendants_tree (app);
fill_callers_list (app);