summaryrefslogtreecommitdiffstats
path: root/src/tree.c
diff options
context:
space:
mode:
authorPatrick McDermott <pj@pehjota.net>2017-10-25 12:36:41 (EDT)
committer Patrick McDermott <pj@pehjota.net>2017-10-25 12:36:41 (EDT)
commitec249526ef406db942067c274415d17fb923c2cc (patch)
tree1581e4e3dd5f324b5c689764a14d3e8e03753867 /src/tree.c
parentc64472f47e5434caddb247ca9e7500111b82f7dc (diff)
downloadmarquee-ec249526ef406db942067c274415d17fb923c2cc.zip
marquee-ec249526ef406db942067c274415d17fb923c2cc.tar.gz
marquee-ec249526ef406db942067c274415d17fb923c2cc.tar.bz2
MqTree: Fix width of pointers in debugging output
And modify configure.ac to search for logl() and add -lm to LIBS.
Diffstat (limited to 'src/tree.c')
-rw-r--r--src/tree.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/src/tree.c b/src/tree.c
index 61db6f6..1363098 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -31,6 +31,10 @@
#if MQ_TREE_DEBUG
+#include <math.h>
+
+#define PRIWxPTR ((int) (logl(UINTPTR_MAX) / logl(16)))
+
static void
debug_print_tree_recurse(MqTree *node, gsize indent)
{
@@ -40,15 +44,16 @@ debug_print_tree_recurse(MqTree *node, gsize indent)
for (i = 0; i < indent; ++i) {
g_print("\t");
}
- g_print("\t0x%" PRIxPTR " (size %d, position %d, "
- "parent 0x%" PRIxPTR ", "
- "siblings 0x%" PRIxPTR " and 0x%" PRIxPTR ", "
- "children 0x%" PRIxPTR " to 0x%" PRIxPTR ")\n",
- (uintptr_t) node, node->size, node->position,
- (uintptr_t) node->parent,
- (uintptr_t) node->prev, (uintptr_t) node->next,
- (uintptr_t) node->first_child,
- (uintptr_t) node->last_child);
+ g_print("\t0x%0*" PRIxPTR " (size %d, position %d, "
+ "parent 0x%0*" PRIxPTR ", "
+ "siblings 0x%0*" PRIxPTR " and 0x%0*" PRIxPTR ", "
+ "children 0x%0*" PRIxPTR " to 0x%0*" PRIxPTR ")\n",
+ PRIWxPTR, (uintptr_t) node, node->size, node->position,
+ PRIWxPTR, (uintptr_t) node->parent,
+ PRIWxPTR, (uintptr_t) node->prev,
+ PRIWxPTR, (uintptr_t) node->next,
+ PRIWxPTR, (uintptr_t) node->first_child,
+ PRIWxPTR, (uintptr_t) node->last_child);
if (node->first_child) {
debug_print_tree_recurse(node->first_child, indent + 1);
@@ -59,7 +64,7 @@ debug_print_tree_recurse(MqTree *node, gsize indent)
static void
debug_print_tree(const gchar *msg, MqTree *node)
{
- g_print("%s 0x%" PRIxPTR ", ", msg, (uintptr_t) node);
+ g_print("%s 0x%0*" PRIxPTR ", ", msg, PRIWxPTR, (uintptr_t) node);
node = node->root;
g_print("new tree (size %d):\n", node->size);
debug_print_tree_recurse(node, 0);
@@ -68,13 +73,14 @@ debug_print_tree(const gchar *msg, MqTree *node)
static void
debug_print_node(MqTree *node)
{
- g_print("\t0x%" PRIxPTR "\n", (uintptr_t) node);
+ g_print("\t0x%0*" PRIxPTR "\n", PRIWxPTR, (uintptr_t) node);
}
static void
debug_print_head(const gchar *head, MqTree *node)
{
- g_print("%s, starting at 0x%" PRIxPTR "\n", head, (uintptr_t) node);
+ g_print("%s, starting at 0x%0*" PRIxPTR "\n",
+ head, PRIWxPTR, (uintptr_t) node);
}
#else /* MQ_TREE_DEBUG */