apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Stoddard" <b...@wstoddard.com>
Subject [PATCH] Update to Brian's patch to allocate brigades out of the bucket allocator
Date Fri, 20 Dec 2002 15:32:11 GMT
If a pool is passed to apr_brigade_create, the brigade is allocated out of the
pool. If the pool is NULL, the brigade is allocated out of the bucket allocator.
We don't want a pool pointer hanging around in a brigade allocated out of the
bucket allocator. That's just asking for trouble.  This patch makes how the
brigade is allocated, either out of the pool or out of the allocator, explicit.

Index: apr_brigade.c
===================================================================
RCS file: /home/cvs/apr-util/buckets/apr_brigade.c,v
retrieving revision 1.55
diff -u -r1.55 apr_brigade.c
--- apr_brigade.c	17 Dec 2002 19:16:39 -0000	1.55
+++ apr_brigade.c	20 Dec 2002 15:17:58 -0000
@@ -95,7 +95,9 @@
         apr_pool_cleanup_kill(b->p, b, brigade_cleanup);
     }
     rv = apr_brigade_cleanup(b);
-    apr_bucket_free(b);
+    if (!b->p) {
+        apr_bucket_free(b);
+    }
     return rv;
 }

@@ -104,7 +106,12 @@
 {
     apr_bucket_brigade *b;

-    b = apr_bucket_alloc(sizeof(*b), list);
+    if (p) {
+        b = apr_palloc(p, sizeof(*b));
+    }
+    else {
+        b = apr_bucket_alloc(sizeof(*b), list);
+    }
     b->p = p;
     b->bucket_alloc = list;



Mime
View raw message