return size;
}
+static bool min_iqs_available(size_t min_iqs, struct btr_node *btrn)
+{
+ struct btr_buffer_reference *br;
+ size_t have = 0, wrap_consumed = 0;
+
+ FOR_EACH_BUFFER_REF(br, btrn) {
+ if (br->wrap_count != 0) {
+ wrap_consumed = br->consumed;
+ continue;
+ }
+ have += br_available_bytes(br);
+ if (have > wrap_consumed + min_iqs)
+ return true;
+ }
+ return false;
+}
/**
* Remove a node from the buffer tree, reconnecting parent and children.
*
int btr_node_status(struct btr_node *btrn, size_t min_iqs,
enum btr_node_type type)
{
- size_t iqs;
-
- assert(btrn);
if (type != BTR_NT_LEAF && btr_no_children(btrn))
return -E_BTR_NO_CHILD;
if (type != BTR_NT_ROOT && btr_eof(btrn))
return 0;
if (type == BTR_NT_ROOT)
return 1;
- iqs = btr_get_input_queue_size(btrn);
- if (iqs == 0) /* we have a parent, because not eof */
- return 0;
- if (iqs < min_iqs && !btr_no_parent(btrn))
- return 0;
- return 1;
+ if (min_iqs_available(min_iqs, btrn))
+ return 1;
+ return btr_no_parent(btrn);
}
/**