jwoolley 01/02/18 17:42:57
Modified: include apr_buckets.h
Log:
Add apr_bucket_delete(), which is a wrapper macro around bucket removal/
destruction. Useful for decreasing code verbosity.
Revision Changes Path
1.80 +23 -6 apr-util/include/apr_buckets.h
Index: apr_buckets.h
===================================================================
RCS file: /home/cvs/apr-util/include/apr_buckets.h,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -d -u -r1.79 -r1.80
--- apr_buckets.h 2001/02/18 00:13:24 1.79
+++ apr_buckets.h 2001/02/19 01:42:56 1.80
@@ -757,16 +757,33 @@
APU_DECLARE(void) apr_bucket_init_types(apr_pool_t *p);
/**
- * free the resources used by a bucket. If multiple buckets refer to
+ * Free the resources used by a bucket. If multiple buckets refer to
* the same resource it is freed when the last one goes away.
+ * @see apr_bucket_delete()
* @param e The bucket to destroy
* @deffunc void apr_bucket_destroy(apr_bucket *e)
*/
-#define apr_bucket_destroy(e) \
- { \
- e->type->destroy(e->data); \
- free(e); \
- }
+#define apr_bucket_destroy(e) do { \
+ e->type->destroy(e->data); \
+ free(e); \
+ } while (0)
+
+/**
+ * Delete a bucket by removing it from its brigade (if any) and then
+ * destroying it.
+ * @tip This mainly acts as an aid in avoiding code verbosity. It is
+ * the preferred exact equivalent to:
+ * <pre>
+ * APR_BUCKET_REMOVE(e);
+ * apr_bucket_destroy(e);
+ * </pre>
+ * @param e The bucket to delete
+ * @deffunc void apr_bucket_delete(apr_bucket *e)
+ */
+#define apr_bucket_delete(e) do { \
+ APR_BUCKET_REMOVE(e);
\
+ apr_bucket_destroy(e);
\
+ } while (0)
/**
* read the data from the bucket