You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by jo...@apache.org on 2004/06/22 18:18:20 UTC

cvs commit: apr-util/buckets apr_buckets_alloc.c

jorton      2004/06/22 09:18:20

  Modified:    buckets  apr_buckets_alloc.c
  Log:
  * 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
  1.15      +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.14
  retrieving revision 1.15
  diff -d -w -u -r1.14 -r1.15
  --- apr_buckets_alloc.c	13 Feb 2004 09:55:25 -0000	1.14
  +++ apr_buckets_alloc.c	22 Jun 2004 16:18:20 -0000	1.15
  @@ -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;
  +
  +#ifdef 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);
  +
  +#ifdef 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,