apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cliff Woolley <cliffwool...@yahoo.com>
Subject apr_brigade_cleanup()
Date Sun, 01 Apr 2001 22:25:10 GMT

Does anybody have any problem with me exposing apr_brigade_cleanup() as a
public function?  It would not replace apr_brigade_destroy(), but it's
useful in some situations (eg Apache's mod_include) where there's a single
brigade object that you'd like to reuse by cleaning it out and putting
more buckets in it later.  mod_include does this already with the brigade
it keeps in its ctx... the availability of apr_brigade_cleanup() to it
would reduce unnecessary code verbosity.  The alternative, of course, is
to say that callers doing this should destroy the brigade when they want
to clean up and create a new one in its place, but that seems like a
waste of cycles and memory to me.

--Cliff


Index: buckets/apr_brigade.c
===================================================================
RCS file: /home/cvs/apr-util/buckets/apr_brigade.c,v
retrieving revision 1.12
diff -u -d -r1.12 apr_brigade.c
--- buckets/apr_brigade.c	2001/02/28 17:35:42	1.12
+++ buckets/apr_brigade.c	2001/04/01 22:18:41
@@ -67,7 +67,7 @@
 #include <sys/uio.h>
 #endif

-static apr_status_t apr_brigade_cleanup(void *data)
+APU_DECLARE(apr_status_t) apr_brigade_cleanup(void *data)
 {
     apr_bucket_brigade *b = data;
     apr_bucket *e;
@@ -85,6 +85,7 @@
      */
     return APR_SUCCESS;
 }
+
 APU_DECLARE(apr_status_t) apr_brigade_destroy(apr_bucket_brigade *b)
 {
     apr_pool_cleanup_kill(b->p, b, apr_brigade_cleanup);
Index: include/apr_buckets.h
===================================================================
RCS file: /home/cvs/apr-util/include/apr_buckets.h,v
retrieving revision 1.87
diff -u -d -r1.87 apr_buckets.h
--- include/apr_buckets.h	2001/03/01 04:46:13	1.87
+++ include/apr_buckets.h	2001/04/01 22:18:42
@@ -589,6 +589,20 @@
 APU_DECLARE(apr_status_t) apr_brigade_destroy(apr_bucket_brigade *b);

 /**
+ * empty out an entire bucket brigade.  This includes destroying all of the
+ * buckets within the bucket brigade's bucket list.  This is similar to
+ * apr_brigade_destroy(), except that it does not deregister the brigade's
+ * pool cleanup function.
+ * @tip Generally, you should use apr_brigade_destroy().  This function
+ *      can be useful in situations where you have a single brigade that
+ *      you wish to reuse many times by destroying all of the buckets in
+ *      the brigade and putting new buckets into it later.
+ * @param b The bucket brigade to clean up
+ * @deffunc apr_status_t apr_brigade_cleanup(apr_bucket_brigade *b)
+ */
+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

--------------------------------------------------------------
   Cliff Woolley
   cliffwoolley@yahoo.com
   Charlottesville, VA



Mime
View raw message