apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jor...@apache.org
Subject cvs commit: apr-util/buckets apr_buckets_alloc.c
Date Fri, 12 Nov 2004 17:16:58 GMT
jorton      2004/11/12 09:16:58

  Modified:    buckets  Tag: APU_0_9_BRANCH apr_buckets_alloc.c
  Log:
  Backport from HEAD:
  
  * buckets/apr_buckets_alloc.c (apr_bucket_alloc_create,
  apr_bucket_alloc_destroy): Cope with a NULL pool->allocator in debug
  mode.
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.13.2.2  +19 -1     apr-util/buckets/apr_buckets_alloc.c
  
  Index: apr_buckets_alloc.c
  ===================================================================
  RCS file: /home/cvs/apr-util/buckets/apr_buckets_alloc.c,v
  retrieving revision 1.13.2.1
  retrieving revision 1.13.2.2
  diff -d -w -u -r1.13.2.1 -r1.13.2.2
  --- apr_buckets_alloc.c	13 Feb 2004 09:52:41 -0000	1.13.2.1
  +++ apr_buckets_alloc.c	12 Nov 2004 17:16:58 -0000	1.13.2.2
  @@ -13,6 +13,8 @@
    * limitations under the License.
    */
   
  +#include <stdlib.h>
  +
   #include "apr_buckets.h"
   #include "apr_allocator.h"
   
  @@ -49,8 +51,18 @@
   APU_DECLARE_NONSTD(apr_bucket_alloc_t *) apr_bucket_alloc_create(apr_pool_t *p)
   {
       apr_allocator_t *allocator = apr_pool_allocator_get(p);
  -    apr_bucket_alloc_t *list = apr_bucket_alloc_create_ex(allocator);
  +    apr_bucket_alloc_t *list;
  +
  +#if APR_POOL_DEBUG
  +    /* may be NULL for debug mode. */
  +    if (allocator == NULL) {
  +        if (apr_allocator_create(&allocator) != APR_SUCCESS) {
  +            abort();
  +        }
  +    }
  +#endif
   
  +    list = apr_bucket_alloc_create_ex(allocator);
       list->pool = p;
       apr_pool_cleanup_register(list->pool, list, alloc_cleanup,
                                 apr_pool_cleanup_null);
  @@ -82,6 +94,12 @@
       }
   
       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
   }
   
   APU_DECLARE_NONSTD(void *) apr_bucket_alloc(apr_size_t size, 
  
  
  

Mime
View raw message