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/include apr_buckets.h
Date Sat, 25 Aug 2001 22:54:56 GMT
jwoolley    01/08/25 15:54:56

  Modified:    buckets  apr_buckets.c apr_buckets_eos.c apr_buckets_file.c
                        apr_buckets_flush.c apr_buckets_heap.c
                        apr_buckets_mmap.c apr_buckets_pipe.c
                        apr_buckets_pool.c apr_buckets_simple.c
                        apr_buckets_socket.c
               include  apr_buckets.h
  Log:
  BUCKETS SMS PHASE 1
  
  s/malloc/apr_sms_malloc/; s/free/apr_sms_free/; Add in a temporary global
  apr_sms_std instance in the buckets code that all buckets will use to get
  their memory from.  Add an apr_sms_t* to the apr_bucket struct and various
  private structures so that the apr_bucket_foo_make() functions and the
  foo_destroy() functions know which SMS to use.  No API changes yet.
  
  Revision  Changes    Path
  1.53      +2 -0      apr-util/buckets/apr_buckets.c
  
  Index: apr_buckets.c
  ===================================================================
  RCS file: /home/cvs/apr-util/buckets/apr_buckets.c,v
  retrieving revision 1.52
  retrieving revision 1.53
  diff -u -d -u -r1.52 -r1.53
  --- apr_buckets.c	2001/07/24 20:36:03	1.52
  +++ apr_buckets.c	2001/08/25 22:54:56	1.53
  @@ -54,6 +54,8 @@
   
   #include "apr_buckets.h"
   
  +APU_DECLARE_DATA apr_sms_t *apr_bucket_global_sms = NULL;
  +
   APU_DECLARE_NONSTD(apr_status_t) apr_bucket_setaside_noop(apr_bucket *data,
                                                             apr_pool_t *pool)
   {
  
  
  
  1.29      +8 -3      apr-util/buckets/apr_buckets_eos.c
  
  Index: apr_buckets_eos.c
  ===================================================================
  RCS file: /home/cvs/apr-util/buckets/apr_buckets_eos.c,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -d -u -r1.28 -r1.29
  --- apr_buckets_eos.c	2001/08/08 05:58:15	1.28
  +++ apr_buckets_eos.c	2001/08/25 22:54:56	1.29
  @@ -53,7 +53,6 @@
    */
   
   #include "apr_buckets.h"
  -#include <stdlib.h>
   
   static apr_status_t eos_read(apr_bucket *b, const char **str, 
                                   apr_size_t *len, apr_read_type_e block)
  @@ -81,10 +80,16 @@
   
   APU_DECLARE(apr_bucket *) apr_bucket_eos_create(void)
   {
  -    apr_bucket *b = (apr_bucket *)malloc(sizeof(*b));
  +    apr_sms_t *sms;
  +    apr_bucket *b;
   
  +    if (!apr_bucket_global_sms) {
  +        apr_sms_std_create(&apr_bucket_global_sms);
  +    }
  +    sms = apr_bucket_global_sms;
  +    b = (apr_bucket *)apr_sms_malloc(sms, sizeof(*b));
       APR_BUCKET_INIT(b);
  -    b->free = free;
  +    b->sms = sms;
       return apr_bucket_eos_make(b);
   }
   
  
  
  
  1.55      +17 -11    apr-util/buckets/apr_buckets_file.c
  
  Index: apr_buckets_file.c
  ===================================================================
  RCS file: /home/cvs/apr-util/buckets/apr_buckets_file.c,v
  retrieving revision 1.54
  retrieving revision 1.55
  diff -u -d -u -r1.54 -r1.55
  --- apr_buckets_file.c	2001/08/18 14:08:03	1.54
  +++ apr_buckets_file.c	2001/08/25 22:54:56	1.55
  @@ -85,10 +85,12 @@
   
   static void file_destroy(void *data)
   {
  -    if (apr_bucket_shared_destroy(data)) {
  +    apr_bucket_file *f = data;
  +
  +    if (apr_bucket_shared_destroy(f)) {
           /* no need to close the file here; it will get
            * done automatically when the pool gets cleaned up */
  -        free(data);
  +        apr_sms_free(f->sms, f);
       }
   }
   
  @@ -186,12 +188,12 @@
       if (filelength > 0) {
           /* for efficiency, we can just build a new apr_bucket struct
            * to wrap around the existing file bucket */
  -        b = malloc(sizeof(*b));
  +        b = (apr_bucket *)apr_sms_malloc(e->sms, sizeof(*b));
           b->start  = fileoffset + (*len);
           b->length = filelength;
           b->data   = a;
           b->type   = &apr_bucket_type_file;
  -        b->free   = free;
  +        b->sms    = e->sms;
           APR_BUCKET_INSERT_AFTER(e, b);
       }
       else {
  @@ -208,14 +210,12 @@
   {
       apr_bucket_file *f;
   
  -    f = malloc(sizeof(*f));
  -    if (f == NULL) {
  -        return NULL;
  -    }
  +    f = (apr_bucket_file *)apr_sms_malloc(b->sms, sizeof(*f));
       f->fd = fd;
       f->readpool = p;
  +    f->sms = b->sms;
   
  -    b = apr_bucket_shared_make(b, f, offset, len);
  +    apr_bucket_shared_make(b, f, offset, len);
       b->type = &apr_bucket_type_file;
   
       return b;
  @@ -225,10 +225,16 @@
                                                    apr_off_t offset,
                                                    apr_size_t len, apr_pool_t *p)
   {
  -    apr_bucket *b = (apr_bucket *)malloc(sizeof(*b));
  +    apr_sms_t *sms;
  +    apr_bucket *b;
   
  +    if (!apr_bucket_global_sms) {
  +        apr_sms_std_create(&apr_bucket_global_sms);
  +    }
  +    sms = apr_bucket_global_sms;
  +    b = (apr_bucket *)apr_sms_malloc(sms, sizeof(*b));
       APR_BUCKET_INIT(b);
  -    b->free = free;
  +    b->sms = sms;
       return apr_bucket_file_make(b, fd, offset, len, p);
   }
   
  
  
  
  1.21      +8 -3      apr-util/buckets/apr_buckets_flush.c
  
  Index: apr_buckets_flush.c
  ===================================================================
  RCS file: /home/cvs/apr-util/buckets/apr_buckets_flush.c,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -d -u -r1.20 -r1.21
  --- apr_buckets_flush.c	2001/08/08 05:58:15	1.20
  +++ apr_buckets_flush.c	2001/08/25 22:54:56	1.21
  @@ -53,7 +53,6 @@
    */
   
   #include "apr_buckets.h"
  -#include <stdlib.h>
   
   static apr_status_t flush_read(apr_bucket *b, const char **str, 
                                   apr_size_t *len, apr_read_type_e block)
  @@ -81,10 +80,16 @@
   
   APU_DECLARE(apr_bucket *) apr_bucket_flush_create(void)
   {
  -    apr_bucket *b = (apr_bucket *)malloc(sizeof(*b));
  +    apr_sms_t *sms;
  +    apr_bucket *b;
   
  +    if (!apr_bucket_global_sms) {
  +        apr_sms_std_create(&apr_bucket_global_sms);
  +    }
  +    sms = apr_bucket_global_sms;
  +    b = (apr_bucket *)apr_sms_malloc(sms, sizeof(*b));
       APR_BUCKET_INIT(b);
  -    b->free = free;
  +    b->sms = sms;
       return apr_bucket_flush_make(b);
   }
   
  
  
  
  1.37      +13 -12    apr-util/buckets/apr_buckets_heap.c
  
  Index: apr_buckets_heap.c
  ===================================================================
  RCS file: /home/cvs/apr-util/buckets/apr_buckets_heap.c,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -d -u -r1.36 -r1.37
  --- apr_buckets_heap.c	2001/08/08 05:58:15	1.36
  +++ apr_buckets_heap.c	2001/08/25 22:54:56	1.37
  @@ -74,7 +74,7 @@
   
       if (apr_bucket_shared_destroy(h)) {
           free(h->base);
  -        free(h);
  +        apr_sms_free(h->sms, h);
       }
   }
   
  @@ -83,18 +83,11 @@
   {
       apr_bucket_heap *h;
   
  -    h = malloc(sizeof(*h));
  -    if (h == NULL) {
  -	return NULL;
  -    }
  +    h = (apr_bucket_heap *)apr_sms_malloc(b->sms, sizeof(*h));
   
       if (copy) {
   	h->alloc_len = length;
   	h->base = malloc(h->alloc_len);
  -	if (h->base == NULL) {
  -	    free(h);
  -	    return NULL;
  -	}
   	memcpy(h->base, buf, length);
       }
       else {
  @@ -104,10 +97,12 @@
   	h->base = (char *) buf;
   	h->alloc_len = length;
       }
  +    h->sms = b->sms;
   
  -    b = apr_bucket_shared_make(b, h, 0, length);
  +    apr_bucket_shared_make(b, h, 0, length);
       b->type = &apr_bucket_type_heap;
   
  +    /* XXX: the w parm is useless and should go away */
       if (w)
           *w = length;
   
  @@ -117,10 +112,16 @@
   APU_DECLARE(apr_bucket *) apr_bucket_heap_create(
   		const char *buf, apr_size_t length, int copy, apr_size_t *w)
   {
  -    apr_bucket *b = (apr_bucket *)malloc(sizeof(*b));
  +    apr_sms_t *sms;
  +    apr_bucket *b;
   
  +    if (!apr_bucket_global_sms) {
  +        apr_sms_std_create(&apr_bucket_global_sms);
  +    }
  +    sms = apr_bucket_global_sms;
  +    b = (apr_bucket *)apr_sms_malloc(sms, sizeof(*b));
       APR_BUCKET_INIT(b);
  -    b->free = free;
  +    b->sms = sms;
       return apr_bucket_heap_make(b, buf, length, copy, w);
   }
   
  
  
  
  1.42      +14 -11    apr-util/buckets/apr_buckets_mmap.c
  
  Index: apr_buckets_mmap.c
  ===================================================================
  RCS file: /home/cvs/apr-util/buckets/apr_buckets_mmap.c,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -d -u -r1.41 -r1.42
  --- apr_buckets_mmap.c	2001/08/08 05:58:15	1.41
  +++ apr_buckets_mmap.c	2001/08/25 22:54:56	1.42
  @@ -55,7 +55,6 @@
   #include "apr_buckets.h"
   #define APR_WANT_MEMFUNC
   #include "apr_want.h"
  -#include <stdlib.h>
   
   #if APR_HAS_MMAP
   
  @@ -82,7 +81,7 @@
       if (apr_bucket_shared_destroy(m)) {
           /* no need to apr_mmap_delete(m->mmap) here... it will
            * get done automatically when the pool gets cleaned up. */
  -        free(m);
  +        apr_sms_free(m->sms, m);
       }
   }
   
  @@ -94,14 +93,12 @@
   {
       apr_bucket_mmap *m;
   
  -    m = malloc(sizeof(*m));
  -    if (m == NULL) {
  -	return NULL;
  -    }
  +    m = (apr_bucket_mmap *)apr_sms_malloc(b->sms, sizeof(*m));
       m->mmap = mm;
  +    m->sms = b->sms;
   
  -    b = apr_bucket_shared_make(b, m, start, length);
  -    b->type     = &apr_bucket_type_mmap;
  +    apr_bucket_shared_make(b, m, start, length);
  +    b->type = &apr_bucket_type_mmap;
   
       return b;
   }
  @@ -110,10 +107,16 @@
   APU_DECLARE(apr_bucket *) apr_bucket_mmap_create(
   		apr_mmap_t *mm, apr_off_t start, apr_size_t length)
   {
  -    apr_bucket *b = (apr_bucket *)malloc(sizeof(*b));
  +    apr_sms_t *sms;
  +    apr_bucket *b;
   
  +    if (!apr_bucket_global_sms) {
  +        apr_sms_std_create(&apr_bucket_global_sms);
  +    }
  +    sms = apr_bucket_global_sms;
  +    b = (apr_bucket *)apr_sms_malloc(sms, sizeof(*b));
       APR_BUCKET_INIT(b);
  -    b->free = free;
  +    b->sms = sms;
       return apr_bucket_mmap_make(b, mm, start, length);
   }
   
  @@ -136,7 +139,7 @@
   
       base = apr_palloc(p, data->length);
       memcpy(base, addr, data->length);
  -    data = apr_bucket_pool_make(data, base, data->length, p);
  +    apr_bucket_pool_make(data, base, data->length, p);
       mmap_destroy(m);
   
       return APR_SUCCESS;
  
  
  
  1.40      +12 -7     apr-util/buckets/apr_buckets_pipe.c
  
  Index: apr_buckets_pipe.c
  ===================================================================
  RCS file: /home/cvs/apr-util/buckets/apr_buckets_pipe.c,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -d -u -r1.39 -r1.40
  --- apr_buckets_pipe.c	2001/08/08 05:58:15	1.39
  +++ apr_buckets_pipe.c	2001/08/25 22:54:56	1.40
  @@ -70,7 +70,7 @@
   
       *str = NULL;
       *len = APR_BUCKET_BUFF_SIZE;
  -    buf = malloc(*len); /* XXX: check for failure? */
  +    buf = malloc(*len);
   
       rv = apr_file_read(p, buf, len);
   
  @@ -96,9 +96,8 @@
        */
       if (*len > 0) {
           apr_bucket_heap *h;
  -        /* Change the current bucket to refer to what we read */
  -        /* XXX: check for failure? */
  -        a = apr_bucket_heap_make(a, buf, *len, 0, NULL);
  +
  +        apr_bucket_heap_make(a, buf, *len, 0, NULL);
           h = a->data;
           h->alloc_len = APR_BUCKET_BUFF_SIZE; /* note the real buffer size */
           *str = buf;
  @@ -106,7 +105,7 @@
       }
       else {
           free(buf);
  -        a = apr_bucket_immortal_make(a, "", 0);
  +        apr_bucket_immortal_make(a, "", 0);
           *str = a->data;
           if (rv == APR_EOF) {
               apr_file_close(p);
  @@ -144,10 +143,16 @@
   
   APU_DECLARE(apr_bucket *) apr_bucket_pipe_create(apr_file_t *p)
   {
  -    apr_bucket *b = (apr_bucket *)malloc(sizeof(*b));
  +    apr_sms_t *sms;
  +    apr_bucket *b;
   
  +    if (!apr_bucket_global_sms) {
  +        apr_sms_std_create(&apr_bucket_global_sms);
  +    }
  +    sms = apr_bucket_global_sms;
  +    b = (apr_bucket *)apr_sms_malloc(sms, sizeof(*b));
       APR_BUCKET_INIT(b);
  -    b->free = free;
  +    b->sms = sms;
       return apr_bucket_pipe_make(b, p);
   }
   
  
  
  
  1.23      +12 -8     apr-util/buckets/apr_buckets_pool.c
  
  Index: apr_buckets_pool.c
  ===================================================================
  RCS file: /home/cvs/apr-util/buckets/apr_buckets_pool.c,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -d -u -r1.22 -r1.23
  --- apr_buckets_pool.c	2001/08/08 05:58:15	1.22
  +++ apr_buckets_pool.c	2001/08/25 22:54:56	1.23
  @@ -116,7 +116,7 @@
            */
           if (apr_bucket_shared_destroy(p)) {
               apr_pool_cleanup_kill(p->pool, p, pool_bucket_cleanup);
  -            free(p);
  +            apr_sms_free(p->heap.sms, p);
           }
       }
       else {
  @@ -134,10 +134,7 @@
   {
       apr_bucket_pool *p;
   
  -    p = malloc(sizeof(*p));
  -    if (p == NULL) {
  -	return NULL;
  -    }
  +    p = (apr_bucket_pool *)apr_sms_malloc(b->sms, sizeof(*p));
   
       /* XXX: we lose the const qualifier here which indicates
        * there's something screwy with the API...
  @@ -147,12 +144,13 @@
       p->base = (char *) buf;
       p->pool = pool;
   
  -    b = apr_bucket_shared_make(b, p, 0, length);
  +    apr_bucket_shared_make(b, p, 0, length);
       b->type = &apr_bucket_type_pool;
   
       /* pre-initialize heap bucket member */
       p->heap.alloc_len = length;
       p->heap.base      = NULL;
  +    p->heap.sms       = b->sms;
   
       apr_pool_cleanup_register(p->pool, p, pool_bucket_cleanup,
                                 apr_pool_cleanup_null);
  @@ -162,10 +160,16 @@
   APU_DECLARE(apr_bucket *) apr_bucket_pool_create(
   		const char *buf, apr_size_t length, apr_pool_t *pool)
   {
  -    apr_bucket *b = (apr_bucket *)malloc(sizeof(*b));
  +    apr_sms_t *sms;
  +    apr_bucket *b;
   
  +    if (!apr_bucket_global_sms) {
  +        apr_sms_std_create(&apr_bucket_global_sms);
  +    }
  +    sms = apr_bucket_global_sms;
  +    b = (apr_bucket *)apr_sms_malloc(sms, sizeof(*b));
       APR_BUCKET_INIT(b);
  -    b->free = free;
  +    b->sms = sms;
       return apr_bucket_pool_make(b, buf, length, pool);
   }
   
  
  
  
  1.33      +19 -18    apr-util/buckets/apr_buckets_simple.c
  
  Index: apr_buckets_simple.c
  ===================================================================
  RCS file: /home/cvs/apr-util/buckets/apr_buckets_simple.c,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -d -u -r1.32 -r1.33
  --- apr_buckets_simple.c	2001/08/08 05:58:15	1.32
  +++ apr_buckets_simple.c	2001/08/25 22:54:56	1.33
  @@ -53,14 +53,11 @@
    */
   
   #include "apr_buckets.h"
  -#include <stdlib.h>
   
   APU_DECLARE_NONSTD(apr_status_t) apr_bucket_simple_copy(apr_bucket *a,
                                                           apr_bucket **b)
   {
  -    if ((*b = malloc(sizeof(**b))) == NULL) {
  -	return APR_ENOMEM;
  -    }
  +    *b = (apr_bucket *)apr_sms_malloc(a->sms, sizeof(**b));
       **b = *a;
   
       return APR_SUCCESS;
  @@ -70,16 +67,12 @@
                                                            apr_size_t point)
   {
       apr_bucket *b;
  -    apr_status_t rv;
   
       if ((point > a->length) || (a->length == (apr_size_t)(-1))) {
   	return APR_EINVAL;
       }
   
  -    rv = apr_bucket_simple_copy(a, &b);
  -    if (rv != APR_SUCCESS) {
  -        return rv;
  -    }
  +    apr_bucket_simple_copy(a, &b);
   
       a->length  = point;
       b->length -= point;
  @@ -105,17 +98,22 @@
       b->length = length;
       b->start  = 0;
       b->type   = &apr_bucket_type_immortal;
  -
       return b;
   }
   
   APU_DECLARE(apr_bucket *) apr_bucket_immortal_create(
   		const char *buf, apr_size_t length)
   {
  -    apr_bucket *b = (apr_bucket *)malloc(sizeof(*b));
  +    apr_sms_t *sms;
  +    apr_bucket *b;
   
  +    if (!apr_bucket_global_sms) {
  +        apr_sms_std_create(&apr_bucket_global_sms);
  +    }
  +    sms = apr_bucket_global_sms;
  +    b = (apr_bucket *)apr_sms_malloc(sms, sizeof(*b));
       APR_BUCKET_INIT(b);
  -    b->free = free;
  +    b->sms = sms;
       return apr_bucket_immortal_make(b, buf, length);
   }
   
  @@ -130,10 +128,7 @@
    */
   static apr_status_t transient_setaside(apr_bucket *b, apr_pool_t *pool)
   {
  -    b = apr_bucket_heap_make(b, (char *)b->data + b->start, b->length, 1, NULL);
  -    if (b == NULL) {
  -        return APR_ENOMEM;
  -    }
  +    apr_bucket_heap_make(b, (char *)b->data + b->start, b->length, 1, NULL);
       return APR_SUCCESS;
   }
   
  @@ -150,10 +145,16 @@
   APU_DECLARE(apr_bucket *) apr_bucket_transient_create(
   		const char *buf, apr_size_t length)
   {
  -    apr_bucket *b = (apr_bucket *)malloc(sizeof(*b));
  +    apr_sms_t *sms;
  +    apr_bucket *b;
   
  +    if (!apr_bucket_global_sms) {
  +        apr_sms_std_create(&apr_bucket_global_sms);
  +    }
  +    sms = apr_bucket_global_sms;
  +    b = (apr_bucket *)apr_sms_malloc(sms, sizeof(*b));
       APR_BUCKET_INIT(b);
  -    b->free = free;
  +    b->sms = sms;
       return apr_bucket_transient_make(b, buf, length);
   }
   
  
  
  
  1.29      +12 -7     apr-util/buckets/apr_buckets_socket.c
  
  Index: apr_buckets_socket.c
  ===================================================================
  RCS file: /home/cvs/apr-util/buckets/apr_buckets_socket.c,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -d -u -r1.28 -r1.29
  --- apr_buckets_socket.c	2001/08/08 05:58:15	1.28
  +++ apr_buckets_socket.c	2001/08/25 22:54:56	1.29
  @@ -70,7 +70,7 @@
   
       *str = NULL;
       *len = APR_BUCKET_BUFF_SIZE;
  -    buf = malloc(*len); /* XXX: check for failure? */
  +    buf = malloc(*len);
   
       rv = apr_recv(p, buf, len);
   
  @@ -99,9 +99,8 @@
        */
       if (*len > 0) {
           apr_bucket_heap *h;
  -        /* Change the current bucket to refer to what we read */
  -        /* XXX: check for failure? */
  -        a = apr_bucket_heap_make(a, buf, *len, 0, NULL);
  +
  +        apr_bucket_heap_make(a, buf, *len, 0, NULL);
           h = a->data;
           h->alloc_len = APR_BUCKET_BUFF_SIZE; /* note the real buffer size */
           *str = buf;
  @@ -109,7 +108,7 @@
       }
       else {
           free(buf);
  -        a = apr_bucket_immortal_make(a, "", 0);
  +        apr_bucket_immortal_make(a, "", 0);
           *str = a->data;
           if (rv == APR_EOF && block == APR_NONBLOCK_READ) {
               /* XXX: this is bogus... should return APR_SUCCESS */
  @@ -139,10 +138,16 @@
   
   APU_DECLARE(apr_bucket *) apr_bucket_socket_create(apr_socket_t *p)
   {
  -    apr_bucket *b = (apr_bucket *)malloc(sizeof(*b));
  +    apr_sms_t *sms;
  +    apr_bucket *b;
   
  +    if (!apr_bucket_global_sms) {
  +        apr_sms_std_create(&apr_bucket_global_sms);
  +    }
  +    sms = apr_bucket_global_sms;
  +    b = (apr_bucket *)apr_sms_malloc(sms, sizeof(*b));
       APR_BUCKET_INIT(b);
  -    b->free = free;
  +    b->sms = sms;
       return apr_bucket_socket_make(b, p);
   }
   
  
  
  
  1.114     +15 -8     apr-util/include/apr_buckets.h
  
  Index: apr_buckets.h
  ===================================================================
  RCS file: /home/cvs/apr-util/include/apr_buckets.h,v
  retrieving revision 1.113
  retrieving revision 1.114
  diff -u -d -u -r1.113 -r1.114
  --- apr_buckets.h	2001/08/23 03:58:34	1.113
  +++ apr_buckets.h	2001/08/25 22:54:56	1.114
  @@ -56,13 +56,14 @@
   #define APR_BUCKETS_H
   
   #include "apu.h"
  +#include "apr.h"
   #include "apr_network_io.h"
   #include "apr_file_io.h"
   #include "apr_general.h"
   #include "apr_mmap.h"
   #include "apr_errno.h"
   #include "apr_ring.h"
  -#include "apr.h"
  +#include "apr_sms.h"
   #if APR_HAVE_SYS_UIO_H
   #include <sys/uio.h>	/* for struct iovec */
   #endif
  @@ -247,13 +248,10 @@
       /** type-dependent data hangs off this pointer */
       void *data;	
       /**
  -     * Pointer to function used to free the bucket. This function should
  -     * always be defined and it should be consistent with the memory
  -     * function used to allocate the bucket. For example, if malloc() is 
  -     * used to allocate the bucket, this pointer should point to free().
  -     * @param e Pointer to the bucket being freed
  +     * Pointer to SMS in which bucket is allocated.  Used when freeing
  +     * the bucket and when allocating for private data structures.
        */
  -    void (*free)(void *e);
  +    apr_sms_t *sms;
   };
   
   /** A list of buckets */
  @@ -275,6 +273,9 @@
       APR_RING_HEAD(apr_bucket_list, apr_bucket) list;
   };
   
  +/* temporary */
  +APU_DECLARE_DATA extern apr_sms_t *apr_bucket_global_sms;
  +
   typedef apr_status_t (*apr_brigade_flush)(apr_bucket_brigade *bb, void *ctx);
   
   /**
  @@ -571,6 +572,8 @@
       char    *base;
       /** how much memory was allocated */
       apr_size_t  alloc_len;
  +    /** The SMS from which this structure was allocated */
  +    apr_sms_t *sms;
   };
   
   typedef struct apr_bucket_pool apr_bucket_pool;
  @@ -615,6 +618,8 @@
       apr_bucket_refcount  refcount;
       /** The mmap this sub_bucket refers to */
       apr_mmap_t *mmap;
  +    /** The SMS from which this structure was allocated */
  +    apr_sms_t *sms;
   };
   #endif
   
  @@ -630,6 +635,8 @@
       /** The pool into which any needed structures should
        *  be created while reading from this file bucket */
       apr_pool_t *readpool;
  +    /** The SMS that this structure was allocated from */
  +    apr_sms_t *sms;
   };
   
   /*  *****  Bucket Brigade Functions  *****  */
  @@ -822,7 +829,7 @@
    */
   #define apr_bucket_destroy(e) do {					\
           (e)->type->destroy((e)->data);					\
  -        (e)->free(e);							\
  +        apr_sms_free((e)->sms, (e));					\
       } while (0)
   
   /**
  
  
  

Mime
View raw message