Return-Path: Delivered-To: apmail-apr-commits-archive@www.apache.org Received: (qmail 18350 invoked from network); 28 May 2008 20:59:38 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 28 May 2008 20:59:38 -0000 Received: (qmail 33104 invoked by uid 500); 28 May 2008 20:59:40 -0000 Delivered-To: apmail-apr-commits-archive@apr.apache.org Received: (qmail 33054 invoked by uid 500); 28 May 2008 20:59:39 -0000 Mailing-List: contact commits-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: Reply-To: dev@apr.apache.org List-Id: Delivered-To: mailing list commits@apr.apache.org Received: (qmail 33045 invoked by uid 99); 28 May 2008 20:59:39 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 28 May 2008 13:59:39 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 28 May 2008 20:58:52 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 8B8412388A0F; Wed, 28 May 2008 13:59:12 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r661080 - in /apr/apr-util/trunk: CHANGES buckets/apr_brigade.c include/apr_buckets.h Date: Wed, 28 May 2008 20:59:12 -0000 To: commits@apr.apache.org From: rpluem@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080528205912.8B8412388A0F@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: rpluem Date: Wed May 28 13:59:11 2008 New Revision: 661080 URL: http://svn.apache.org/viewvc?rev=661080&view=rev Log: * Introduce apr_brigade_split_ex. apr_brigade_split_ex allows to reuse an already existing brigade instead of creating a new one. Thus it can be used to lower the memory footprint where brigades need to be split many times during the lifetime of a pool. Modified: apr/apr-util/trunk/CHANGES apr/apr-util/trunk/buckets/apr_brigade.c apr/apr-util/trunk/include/apr_buckets.h Modified: apr/apr-util/trunk/CHANGES URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/CHANGES?rev=661080&r1=661079&r2=661080&view=diff ============================================================================== --- apr/apr-util/trunk/CHANGES [utf-8] (original) +++ apr/apr-util/trunk/CHANGES [utf-8] Wed May 28 13:59:11 2008 @@ -1,6 +1,10 @@ -*- coding: utf-8 -*- Changes with APR-util 1.4.0 + *) Add apr_brigade_split_ex for reusing existing brigades in situation where + brigades need to be split often during the lifetime of a pool.i + [Ruediger Pluem] + *) apr_reslist: destroy all resources in apr_cleanup. PR 45086 [Nick Kew] Modified: apr/apr-util/trunk/buckets/apr_brigade.c URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/buckets/apr_brigade.c?rev=661080&r1=661079&r2=661080&view=diff ============================================================================== --- apr/apr-util/trunk/buckets/apr_brigade.c (original) +++ apr/apr-util/trunk/buckets/apr_brigade.c Wed May 28 13:59:11 2008 @@ -68,13 +68,18 @@ return b; } -APU_DECLARE(apr_bucket_brigade *) apr_brigade_split(apr_bucket_brigade *b, - apr_bucket *e) +APU_DECLARE(apr_bucket_brigade *) apr_brigade_split_ex(apr_bucket_brigade *b, + apr_bucket *e, + apr_bucket_brigade *a) { - apr_bucket_brigade *a; apr_bucket *f; - a = apr_brigade_create(b->p, b->bucket_alloc); + if (!a) { + a = apr_brigade_create(b->p, b->bucket_alloc); + } + else if (!APR_BRIGADE_EMPTY(a)) { + apr_brigade_cleanup(a); + } /* Return an empty brigade if there is nothing left in * the first brigade to split off */ @@ -90,6 +95,12 @@ return a; } +APU_DECLARE(apr_bucket_brigade *) apr_brigade_split(apr_bucket_brigade *b, + apr_bucket *e) +{ + return apr_brigade_split_ex(b, e, NULL); +} + APU_DECLARE(apr_status_t) apr_brigade_partition(apr_bucket_brigade *b, apr_off_t point, apr_bucket **after_point) Modified: apr/apr-util/trunk/include/apr_buckets.h URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/include/apr_buckets.h?rev=661080&r1=661079&r2=661080&view=diff ============================================================================== --- apr/apr-util/trunk/include/apr_buckets.h (original) +++ apr/apr-util/trunk/include/apr_buckets.h Wed May 28 13:59:11 2008 @@ -679,6 +679,23 @@ APU_DECLARE(apr_status_t) apr_brigade_cleanup(void *data); /** + * Move the buckets from the tail end of the existing brigade @param b into + * the brigade @param a. If @param a is NULL a new brigade is created. Buckets + * from @param e to the last bucket (inclusively) of brigade @param b are moved + * from @param b to the returned brigade @param a. + * @param b The brigade to split + * @param e The first bucket to move + * @param a The brigade which should be used for the result or NULL if + * a new brigade should be created. + * @return The brigade supplied in @param a or a new one if @param a was NULL. + * @warning Note that this function allocates a new brigade if @param a is + * NULL so memory consumption should be carefully considered. + */ +APU_DECLARE(apr_bucket_brigade *) apr_brigade_split_ex(apr_bucket_brigade *b, + apr_bucket *e, + apr_bucket_brigade *a); + +/** * Create a new bucket brigade and move the buckets from the tail end * of an existing brigade into the new brigade. Buckets from * @param e to the last bucket (inclusively) of brigade @param b