apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rpl...@apache.org
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 GMT
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



Mime
View raw message