View | Details | Raw Unified | Return to bug 53740
Collapse All | Expand All

(-)buckets/apr_brigade.c (-23 / +1 lines)
Lines 617-645 Link Here
617
                                           apr_brigade_flush flush, void *ctx,
617
                                           apr_brigade_flush flush, void *ctx,
618
                                           const char *str)
618
                                           const char *str)
619
{
619
{
620
    apr_size_t len = strlen(str);
620
    return apr_brigade_write(bb, flush, ctx, str, strlen(str));
621
    apr_bucket *bkt = APR_BRIGADE_LAST(bb);
622
    if (!APR_BRIGADE_EMPTY(bb) && APR_BUCKET_IS_HEAP(bkt)) {
623
        /* If there is enough space available in a heap bucket
624
         * at the end of the brigade, copy the string directly
625
         * into the heap bucket
626
         */
627
        apr_bucket_heap *h = bkt->data;
628
        apr_size_t bytes_avail = h->alloc_len - bkt->length;
629
630
        if (bytes_avail >= len) {
631
            char *buf = h->base + bkt->start + bkt->length;
632
            memcpy(buf, str, len);
633
            bkt->length += len;
634
            return APR_SUCCESS;
635
        }
636
    }
637
638
    /* If the string could not be copied into an existing heap
639
     * bucket, delegate the work to apr_brigade_write(), which
640
     * knows how to grow the brigade
641
     */
642
    return apr_brigade_write(bb, flush, ctx, str, len);
643
}
621
}
644
622
645
APR_DECLARE_NONSTD(apr_status_t) apr_brigade_putstrs(apr_bucket_brigade *b, 
623
APR_DECLARE_NONSTD(apr_status_t) apr_brigade_putstrs(apr_bucket_brigade *b, 

Return to bug 53740