X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=buffer_tree.c;h=dfecf10a24906f2e165ed9368f69c23e99f6e291;hp=d12dcde7b5055b426f40ec116f0d5533213ef522;hb=c09e475689a31b2f11a51faf379c72b9d0be73ab;hpb=172e2ef5bc06aee5a68c37e10b1a8918895c23f9 diff --git a/buffer_tree.c b/buffer_tree.c index d12dcde7..dfecf10a 100644 --- a/buffer_tree.c +++ b/buffer_tree.c @@ -622,11 +622,16 @@ next: if (sz1 + sz2 >= dest_size) break; } + /* + * If the second buffer is large, we only take the first part of it to + * avoid having to memcpy() huge buffers. + */ + sz2 = PARA_MIN(sz2, (size_t)(64 * 1024)); if (!wbr) { assert(buf1); if (!buf2) /* nothing to do */ return; - /* make a new wrap buffer combining buf1 and buf 2. */ + /* Make a new wrap buffer combining buf1 and buf2. */ sz = sz1 + sz2; buf = para_malloc(sz); PARA_DEBUG_LOG("merging input buffers: (%p:%zu, %p:%zu) -> %p:%zu\n", @@ -745,6 +750,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 +777,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;