From 64b2627c4a69db9ad4f0bc170b08a6bc66412b44 Mon Sep 17 00:00:00 2001 From: Soeren Sandmann Date: Sun, 6 Nov 2005 23:27:17 +0000 Subject: [PATCH] Make these function call back with GLists rather than GSLists. Sun Nov 6 18:31:23 2005 Soeren Sandmann * stackstash.c (stack_stash_foreach): * stackstash.c (stack_node_foreach_trace): Make these function call back with GLists rather than GSLists. * profile.c (add_trace_to_tree): Iterate backwards instead of copying the list. --- ChangeLog | 9 +++++++++ collector.c | 10 +++++----- profile.c | 9 +++------ stackstash.c | 12 ++++++++---- stackstash.h | 4 ++-- 5 files changed, 27 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 586885d2..ad613e54 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Sun Nov 6 18:31:23 2005 Soeren Sandmann + + * stackstash.c (stack_stash_foreach): + * stackstash.c (stack_node_foreach_trace): Make these function + call back with GLists rather than GSLists. + + * profile.c (add_trace_to_tree): Iterate backwards instead of + copying the list. + Sun Nov 6 17:06:52 2005 Soeren Sandmann * profile.c (add_trace_to_tree): Turn this function into a diff --git a/collector.c b/collector.c index 4b376c9b..e2ea3877 100644 --- a/collector.c +++ b/collector.c @@ -256,16 +256,16 @@ lookup_symbol (Process *process, gpointer address, GHashTable *unique_symbols) } static void -resolve_symbols (GSList *trace, gint size, gpointer data) +resolve_symbols (GList *trace, gint size, gpointer data) { - GSList *slist; + GList *list; ResolveInfo *info = data; - Process *process = g_slist_last (trace)->data; + Process *process = g_list_last (trace)->data; GPtrArray *resolved_trace = g_ptr_array_new (); - for (slist = trace; slist && slist->next; slist = slist->next) + for (list = trace; list && list->next; list = list->next) { - gpointer address = slist->data; + gpointer address = list->data; char *symbol; symbol = lookup_symbol (process, address, info->unique_symbols); diff --git a/profile.c b/profile.c index c3eb9820..d50afaba 100644 --- a/profile.c +++ b/profile.c @@ -234,17 +234,15 @@ profile_new (StackStash *stash) } static void -add_trace_to_tree (GSList *trace, gint size, gpointer data) +add_trace_to_tree (GList *trace, gint size, gpointer data) { - GSList *list; + GList *list; GPtrArray *nodes_to_unmark = g_ptr_array_new (); ProfileDescendant *parent = NULL; int i, len; ProfileDescendant **tree = data; - trace = g_slist_reverse (g_slist_copy (trace)); - - for (list = trace; list != NULL; list = list->next) + for (list = g_list_last (trace); list != NULL; list = list->prev) { gpointer address = list->data; ProfileDescendant *match = NULL; @@ -321,7 +319,6 @@ add_trace_to_tree (GSList *trace, gint size, gpointer data) } g_ptr_array_free (nodes_to_unmark, TRUE); - g_slist_free (trace); } ProfileDescendant * diff --git a/stackstash.c b/stackstash.c index 1a4c7d36..3a285bc4 100644 --- a/stackstash.c +++ b/stackstash.c @@ -127,17 +127,20 @@ stack_stash_add_trace (StackStash *stash, static void do_callback (StackNode *node, - const GSList *trace, + GList *trace, StackFunction func, gpointer data) { - GSList link; + GList link; if (!node) return; - link.next = (GSList *)trace; + if (trace) + trace->prev = &link; + link.next = trace; link.data = node->address; + link.prev = NULL; if (node->size) func (&link, node->size, data); @@ -159,10 +162,11 @@ stack_node_foreach_trace (StackNode *node, StackFunction func, gpointer data) { - GSList link; + GList link; link.next = NULL; link.data = node->address; + link.prev = NULL; if (node->size) func (&link, node->size, data); diff --git a/stackstash.h b/stackstash.h index 0bd8909e..0be55c23 100644 --- a/stackstash.h +++ b/stackstash.h @@ -41,8 +41,8 @@ struct StackNode gboolean toplevel; }; -typedef void (* StackFunction) (GSList *trace, - gint size, +typedef void (* StackFunction) (GList *trace, + gint size, gpointer data); /* Stach */