summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McDermott <pj@pehjota.net>2017-10-23 22:49:42 (EDT)
committer Patrick McDermott <pj@pehjota.net>2017-10-23 23:00:32 (EDT)
commit43e56dfed6deda657150c33cbaea700c60543cd0 (patch)
tree8ba0dfe1fcf8c3a603d1f301c64d6eb4e09b666f
parent0a3b4ba3b720bef17f17fa7c218670e0bbfd1032 (diff)
downloadmarquee-43e56dfed6deda657150c33cbaea700c60543cd0.zip
marquee-43e56dfed6deda657150c33cbaea700c60543cd0.tar.gz
marquee-43e56dfed6deda657150c33cbaea700c60543cd0.tar.bz2
MqTree: Add foreach debugging output
-rw-r--r--src/tree.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/tree.c b/src/tree.c
index 2a146f3..0034d09 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -58,9 +58,23 @@ print_tree(MqTree *node)
print_tree_recurse(node, 0);
}
+static void
+print_node(MqTree *node)
+{
+ g_print("\t0x%" PRIxPTR "\n", (uintptr_t) node);
+}
+
+static void
+print_head(const gchar *head, MqTree *node)
+{
+ g_print("%s, at 0x%" PRIxPTR "\n", head, (uintptr_t) node);
+}
+
#else /* MQ_TREE_DEBUG */
#define print_tree(node)
+#define print_node(node)
+#define print_head(head, node)
#endif /* MQ_TREE_DEBUG */
@@ -205,6 +219,7 @@ foreach(MqTree *node, gboolean (*cb)(MqTree *node, gpointer user_data),
{
for (; node; node = node->next) {
/* XXX: Warning: Does not skip root node */
+ print_node(node);
if (cb(node, user_data) == MQ_TREE_STOP) {
return MQ_TREE_STOP;
}
@@ -224,6 +239,8 @@ void
mq_tree_foreach(MqTree *node, gboolean (*cb)(MqTree *node, gpointer user_data),
gpointer user_data)
{
+ print_head("foreach", node);
+
foreach(node->root->first_child, cb, user_data);
}
@@ -232,6 +249,7 @@ foreach_from(MqTree *node, gboolean (*cb)(MqTree *node, gpointer user_data),
gpointer user_data)
{
for (; node; node = node->next) {
+ print_node(node);
if (cb(node, user_data) == MQ_TREE_STOP) {
return MQ_TREE_STOP;
}
@@ -256,5 +274,7 @@ void
mq_tree_foreach_from(MqTree *node,
gboolean (*cb)(MqTree *node, gpointer user_data), gpointer user_data)
{
+ print_head("foreach from", node);
+
foreach_from(node, cb, user_data);
}