apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s.@apache.org
Subject svn commit: r1435605 - /apr/apr/trunk/buckets/apr_buckets_alloc.c
Date Sat, 19 Jan 2013 17:04:50 GMT
Author: sf
Date: Sat Jan 19 17:04:50 2013
New Revision: 1435605

URL: http://svn.apache.org/viewvc?rev=1435605&view=rev
Log:
Revert r789061, r758414, and r758398 which are leftovers of the palloc uses
malloc experiment that were forgotten when reverting to the old code in
r795598.

This fixes the apr_allocator created by apr_bucket_alloc_create() being leaked
by apr_bucket_alloc_destroy.


Modified:
    apr/apr/trunk/buckets/apr_buckets_alloc.c

Modified: apr/apr/trunk/buckets/apr_buckets_alloc.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/buckets/apr_buckets_alloc.c?rev=1435605&r1=1435604&r2=1435605&view=diff
==============================================================================
--- apr/apr/trunk/buckets/apr_buckets_alloc.c (original)
+++ apr/apr/trunk/buckets/apr_buckets_alloc.c Sat Jan 19 17:04:50 2013
@@ -47,22 +47,37 @@ static apr_status_t alloc_cleanup(void *
 
     apr_allocator_free(list->allocator, list->blocks);
 
-    apr_allocator_destroy(list->allocator);
+#if APR_POOL_DEBUG
+    if (list->pool && list->allocator != apr_pool_allocator_get(list->pool))
{
+        apr_allocator_destroy(list->allocator);
+    }
+#endif
 
     return APR_SUCCESS;
 }
 
 APR_DECLARE_NONSTD(apr_bucket_alloc_t *) apr_bucket_alloc_create(apr_pool_t *p)
 {
-    apr_allocator_t *allocator;
+    apr_allocator_t *allocator = apr_pool_allocator_get(p);
     apr_bucket_alloc_t *list;
 
-    if (apr_allocator_create(&allocator) != APR_SUCCESS
-        || (list = apr_bucket_alloc_create_ex(allocator)) == NULL) {
-        apr_abortfunc_t fn = apr_pool_abort_get(p);
-        if (fn)
-            (fn)(APR_ENOMEM);
-        abort();
+#if APR_POOL_DEBUG
+    /* may be NULL for debug mode. */
+    if (allocator == NULL) {
+        if (apr_allocator_create(&allocator) != APR_SUCCESS) {
+            apr_abortfunc_t fn = apr_pool_abort_get(p);
+            if (fn)
+                (fn)(APR_ENOMEM);
+            abort();
+        }
+    }
+#endif
+    list = apr_bucket_alloc_create_ex(allocator);
+    if (list == NULL) {
+            apr_abortfunc_t fn = apr_pool_abort_get(p);
+            if (fn)
+                (fn)(APR_ENOMEM);
+            abort();
     }
     list->pool = p;
     apr_pool_cleanup_register(list->pool, list, alloc_cleanup,
@@ -99,6 +114,11 @@ APR_DECLARE_NONSTD(void) apr_bucket_allo
 
     apr_allocator_free(list->allocator, list->blocks);
 
+#if APR_POOL_DEBUG
+    if (list->pool && list->allocator != apr_pool_allocator_get(list->pool))
{
+        apr_allocator_destroy(list->allocator);
+    }
+#endif
 }
 
 APR_DECLARE_NONSTD(void *) apr_bucket_alloc(apr_size_t size, 



Mime
View raw message