apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Orton <jor...@redhat.com>
Subject Re: Clarification: apr_brigade_split()
Date Wed, 25 Oct 2006 09:48:47 GMT
On Wed, Oct 25, 2006 at 11:03:05AM +0200, Graham Leggett wrote:
> On Wed, October 25, 2006 2:56 am, Davi Arnaut wrote:
> >>> Is the brigade in a the leftmost part of the brigade, or the rightmost
> >>> part of the brigade?
> >>
> >> All buckets before the bucket *e are removed from the brigade and placed
> >> on the new brigade.
> >
> > Oops. All buckets before the bucket *e are kept on the brigade.
> So is it true to say that when apr_brigade_split runs, all buckets after
> and including bucket e are removed from the original brigade and are
> returned as a new brigade, and that the original brigade now contains all
> buckets before bucket e?

Correct - does the below read better?

apr_brigade_split() should be used extremely carefully since it always 
allocates a new brigade.  If an output filter is written in such a way 
that it may call apr_brigade_split() for multiple invocations per 
response, then it will use memory proportional to response size.

--- include/apr_buckets.h	(revision 451235)
+++ include/apr_buckets.h	(working copy)
@@ -679,13 +679,15 @@
 APU_DECLARE(apr_status_t) apr_brigade_cleanup(void *data);
- * Split a bucket brigade into two, such that the given bucket is the
- * first in the new bucket brigade. This function is useful when a
- * filter wants to pass only the initial part of a brigade to the next
- * filter.
- * @param b The brigade to split
- * @param e The first element of the new brigade
+ * 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
+ * are moved from @param b to the returned brigade.
+ * @param b The brigade to split 
+ * @param e The first bucket to move
  * @return The new brigade
+ * @warning Note that this function always allocates a new brigade
+ * so memory consumption should be carefully considered.
 APU_DECLARE(apr_bucket_brigade *) apr_brigade_split(apr_bucket_brigade *b,
                                                     apr_bucket *e);

View raw message