From 8b377cf9ce039dbfdfdd128abaa0c3ed93dff941 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Mon, 23 Oct 2017 16:11:52 -0400 Subject: mq_tree_seek(): Fix assertion failures in recursive calls --- (limited to 'src/tree.c') diff --git a/src/tree.c b/src/tree.c index fc82cf6..7479e80 100644 --- a/src/tree.c +++ b/src/tree.c @@ -122,13 +122,8 @@ mq_tree_remove(MqTree *node) } MqTree * -mq_tree_seek(MqTree *node, gint offset) +seek(MqTree *node, gint offset) { - /* XXX: Only forward seeking from a tree's root is supported. */ - g_assert(node); - g_assert(node->position == 0); - g_assert(offset > 0); - /* Skip forward to the containing subtree. */ while (node && node->position + node->size <= offset) { node = node->next; @@ -145,7 +140,18 @@ mq_tree_seek(MqTree *node, gint offset) } /* Recurse down the subtree. */ - return mq_tree_seek(node->first_child, offset); + return seek(node->first_child, offset); +} + +MqTree * +mq_tree_seek(MqTree *node, gint offset) +{ + /* XXX: Only forward seeking from a tree's root is supported. */ + g_assert(node); + g_assert(node->position == 0); + g_assert(offset > 0); + + return seek(node, offset); } static gboolean -- cgit v0.9.1