apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwool...@apache.org
Subject cvs commit: apr-util/buckets apr_buckets_alloc.c
Date Wed, 10 Apr 2002 16:53:39 GMT
jwoolley    02/04/10 09:53:39

  Modified:    buckets  apr_buckets_alloc.c
  Log:
  register a cleanup on the pool passed to apr_bucket_alloc_create().  there
  were mixed feelings in the group about whether we should do this or not,
  but it seems that the majority feel it *should* be done.  it's more consistent
  with the rest of APR this way I suppose.
  
  Revision  Changes    Path
  1.7       +14 -0     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.6
  retrieving revision 1.7
  diff -u -d -u -r1.6 -r1.7
  --- apr_buckets_alloc.c	1 Apr 2002 05:41:39 -0000	1.6
  +++ apr_buckets_alloc.c	10 Apr 2002 16:53:38 -0000	1.7
  @@ -71,11 +71,18 @@
    *  structures can be allocated.
    */
   struct apr_bucket_alloc_t {
  +    apr_pool_t *pool;
       apr_allocator_t *allocator;
       node_header_t *freelist;
       apr_memnode_t *blocks;
   };
   
  +static apr_status_t alloc_cleanup(void *data)
  +{
  +    apr_bucket_alloc_destroy(data);
  +    return APR_SUCCESS;
  +}
  +
   APU_DECLARE_NONSTD(apr_bucket_alloc_t *) apr_bucket_alloc_create(apr_pool_t *p)
   {
       apr_allocator_t *allocator;
  @@ -85,16 +92,23 @@
       apr_allocator_create(&allocator);
       block = apr_allocator_alloc(allocator, ALLOC_AMT);
       list = (apr_bucket_alloc_t *)block->first_avail;
  +    list->pool = p;
       list->allocator = allocator;
       list->freelist = NULL;
       list->blocks = block;
       block->first_avail += APR_ALIGN_DEFAULT(sizeof(*list));
  +
  +    apr_pool_cleanup_register(list->pool, list, alloc_cleanup,
  +                              apr_pool_cleanup_null);
  +
       return list;
   }
   
   APU_DECLARE_NONSTD(void) apr_bucket_alloc_destroy(apr_bucket_alloc_t *list)
   {
       apr_allocator_t *allocator = list->allocator;
  +
  +    apr_pool_cleanup_kill(list->pool, list, alloc_cleanup);
   
       apr_allocator_free(allocator, list->blocks);
       apr_allocator_destroy(allocator);
  
  
  

Mime
View raw message