]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - buffer_tree.c
Fix stream grabbing.
[paraslash.git] / buffer_tree.c
index d12dcde7b5055b426f40ec116f0d5533213ef522..8aa66b6c7efce8a51e37ab2b52f4102f074d936d 100644 (file)
@@ -745,6 +745,25 @@ void btr_log_tree(struct btr_node *btrn, int loglevel)
        return log_tree_recursively(btrn, loglevel, 0);
 }
 
+/*
+ * \return \a root if \a name is \p NULL.
+ */
+struct btr_node *btr_search_node(const char *name, struct btr_node *root)
+{
+       struct btr_node *ch;
+
+       if (!name)
+               return root;
+       if (!strcmp(root->name, name))
+               return root;
+       FOR_EACH_CHILD(ch, root) {
+               struct btr_node *result = btr_search_node(name, ch);
+               if (result)
+                       return result;
+       }
+       return NULL;
+}
+
 /** 640K ought to be enough for everybody ;) */
 #define BTRN_MAX_PENDING (640 * 1024)
 
@@ -753,6 +772,8 @@ int btr_node_status(struct btr_node *btrn, size_t min_iqs,
 {
        size_t iqs;
 
+       if (!btrn)
+               return 0;
        if (type != BTR_NT_LEAF) {
                if (btr_no_children(btrn))
                        return -E_BTR_NO_CHILD;