apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rpl...@apache.org
Subject svn commit: r661088 - in /apr/apr-util/branches/1.3.x: CHANGES buckets/apr_brigade.c include/apr_buckets.h
Date Wed, 28 May 2008 21:15:35 GMT
Author: rpluem
Date: Wed May 28 14:15:35 2008
New Revision: 661088

URL: http://svn.apache.org/viewvc?rev=661088&view=rev
Log:
Merge r661080 from trunk:

* 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.

Submitted by: rpluem
Reviewed by: rpluem

Modified:
    apr/apr-util/branches/1.3.x/CHANGES
    apr/apr-util/branches/1.3.x/buckets/apr_brigade.c
    apr/apr-util/branches/1.3.x/include/apr_buckets.h

Modified: apr/apr-util/branches/1.3.x/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.3.x/CHANGES?rev=661088&r1=661087&r2=661088&view=diff
==============================================================================
--- apr/apr-util/branches/1.3.x/CHANGES [utf-8] (original)
+++ apr/apr-util/branches/1.3.x/CHANGES [utf-8] Wed May 28 14:15:35 2008
@@ -1,6 +1,10 @@
                                                      -*- coding: utf-8 -*-
 Changes with APR-util 1.3.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.
+     [Ruediger Pluem]
+
   *) Amend apr_reslist to expire resources whose idle time exceeds ttl.
      PR 42841 [Tom Donovan, Nick Kew, Ruediger Pluem]
 

Modified: apr/apr-util/branches/1.3.x/buckets/apr_brigade.c
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.3.x/buckets/apr_brigade.c?rev=661088&r1=661087&r2=661088&view=diff
==============================================================================
--- apr/apr-util/branches/1.3.x/buckets/apr_brigade.c (original)
+++ apr/apr-util/branches/1.3.x/buckets/apr_brigade.c Wed May 28 14:15:35 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/branches/1.3.x/include/apr_buckets.h
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.3.x/include/apr_buckets.h?rev=661088&r1=661087&r2=661088&view=diff
==============================================================================
--- apr/apr-util/branches/1.3.x/include/apr_buckets.h (original)
+++ apr/apr-util/branches/1.3.x/include/apr_buckets.h Wed May 28 14:15:35 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