Use stack_node_new() o (profile_load): Use set_root() instead of

2006-11-19  Soren Sandmann <sandmann@redhat.com>

        * profile.c (profile_load): Use stack_node_new() o
        (profile_load): Use set_root() instead of new_from_root();

        * stackstash.c (stack_stash_new_from_root): Delete this function
        (stack_stash_set_root): Add this function
        (stack_node_new): Export this function
This commit is contained in:
Soren Sandmann
2006-11-20 04:08:01 +00:00
committed by Søren Sandmann Pedersen
parent 9af533a11f
commit 0b718ee95c
4 changed files with 23 additions and 14 deletions

View File

@ -1,3 +1,12 @@
2006-11-19 Soren Sandmann <sandmann@redhat.com>
* profile.c (profile_load): Use stack_node_new() o
(profile_load): Use set_root() instead of new_from_root();
* stackstash.c (stack_stash_new_from_root): Delete this function
(stack_stash_set_root): Add this function
(stack_node_new): Export this function
2006-11-19 Soren Sandmann <sandmann@redhat.com> 2006-11-19 Soren Sandmann <sandmann@redhat.com>
* binparser.h: Declare bin_parser_free(); * binparser.h: Declare bin_parser_free();

View File

@ -199,11 +199,13 @@ profile_load (const char *filename, GError **err)
sfile_end_get (input, "object", string); sfile_end_get (input, "object", string);
} }
sfile_end_get (input, "objects", NULL); sfile_end_get (input, "objects", NULL);
profile->stash = stack_stash_new ((GDestroyNotify)g_free);
n = sfile_begin_get_list (input, "nodes"); n = sfile_begin_get_list (input, "nodes");
for (i = 0; i < n; ++i) for (i = 0; i < n; ++i)
{ {
StackNode *node = g_new (StackNode, 1); StackNode *node = stack_node_new ();
sfile_begin_get_record (input, "node"); sfile_begin_get_record (input, "node");
@ -225,7 +227,7 @@ profile_load (const char *filename, GError **err)
sformat_free (format); sformat_free (format);
sfile_input_free (input); sfile_input_free (input);
profile->stash = stack_stash_new_from_root (root, (GDestroyNotify)g_free); stack_stash_set_root (profile->stash, root);
return profile; return profile;
} }

View File

@ -27,7 +27,7 @@ struct StackStash
GDestroyNotify destroy; GDestroyNotify destroy;
}; };
static StackNode * StackNode *
stack_node_new (void) stack_node_new (void)
{ {
StackNode *node = g_new (StackNode, 1); StackNode *node = g_new (StackNode, 1);
@ -296,15 +296,13 @@ build_hash_table (StackNode *node,
stash->nodes_by_data, node->address, node); stash->nodes_by_data, node->address, node);
} }
StackStash * void
stack_stash_new_from_root (StackNode *root, stack_stash_set_root (StackStash *stash,
GDestroyNotify destroy) StackNode *root)
{ {
StackStash *stash = create_stack_stash (destroy); g_return_if_fail (stash->root == NULL);
g_return_if_fail (g_hash_table_size (stash->nodes_by_data) == 0);
stash->root = root;
stash->root = root;
build_hash_table (stash->root, stash); build_hash_table (stash->root, stash);
return stash;
} }

View File

@ -49,8 +49,7 @@ typedef void (* StackNodeFunc) (StackNode *node,
/* Stach */ /* Stach */
StackStash *stack_stash_new (GDestroyNotify destroy); StackStash *stack_stash_new (GDestroyNotify destroy);
StackStash *stack_stash_new_from_root (StackNode *root, StackNode * stack_node_new (void);
GDestroyNotify destroy);
void stack_stash_add_trace (StackStash *stash, void stack_stash_add_trace (StackStash *stash,
gulong *addrs, gulong *addrs,
gint n_addrs, gint n_addrs,
@ -69,6 +68,7 @@ void stack_stash_foreach_by_address (StackStash *stash,
StackNode *stack_stash_get_root (StackStash *stash); StackNode *stack_stash_get_root (StackStash *stash);
StackStash *stack_stash_ref (StackStash *stash); StackStash *stack_stash_ref (StackStash *stash);
void stack_stash_unref (StackStash *stash); void stack_stash_unref (StackStash *stash);
void stack_stash_set_root (StackStash *stash,
StackNode *root);
#endif #endif