Return-Path: Delivered-To: apmail-apache-cvs-archive@apache.org Received: (qmail 79665 invoked by uid 500); 18 Jul 2000 00:32:33 -0000 Mailing-List: contact apache-cvs-help@apache.org; run by ezmlm Precedence: bulk X-No-Archive: yes Reply-To: new-httpd@apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list apache-cvs@apache.org Received: (qmail 79654 invoked by uid 500); 18 Jul 2000 00:32:33 -0000 Delivered-To: apmail-apache-2.0-cvs@apache.org Date: 18 Jul 2000 00:32:32 -0000 Message-ID: <20000718003232.79650.qmail@locus.apache.org> From: rbb@locus.apache.org To: apache-2.0-cvs@apache.org Subject: cvs commit: apache-2.0/src/lib/apr/buckets ap_buf.c ap_eos_buf.c ap_mmap_buf.c ap_rmem_buf.c ap_rwmem_buf.c apr_buf.h rbb 00/07/17 17:32:32 Modified: src/lib/apr/buckets ap_buf.c ap_eos_buf.c ap_mmap_buf.c ap_rmem_buf.c ap_rwmem_buf.c apr_buf.h Log: Add a split function for buckets. This basically just takes one bucket and makes it two buckets. This is useful if you want to insert something in the middle of some data already in the brigade. Revision Changes Path 1.14 +0 -1 apache-2.0/src/lib/apr/buckets/ap_buf.c Index: ap_buf.c =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/buckets/ap_buf.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- ap_buf.c 2000/07/17 23:49:35 1.13 +++ ap_buf.c 2000/07/18 00:32:31 1.14 @@ -325,4 +325,3 @@ return res; } - 1.3 +2 -0 apache-2.0/src/lib/apr/buckets/ap_eos_buf.c Index: ap_eos_buf.c =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/buckets/ap_eos_buf.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ap_eos_buf.c 2000/07/17 23:49:35 1.2 +++ ap_eos_buf.c 2000/07/18 00:32:31 1.3 @@ -78,6 +78,8 @@ newbuf->color = AP_BUCKET_eos; newbuf->getstr = eos_get_str; newbuf->getlen = eos_get_len; + newbuf->insert = NULL; + newbuf->split = NULL; newbuf->free = NULL; newbuf->data = NULL; 1.6 +25 -5 apache-2.0/src/lib/apr/buckets/ap_mmap_buf.c Index: ap_mmap_buf.c =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/buckets/ap_mmap_buf.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- ap_mmap_buf.c 2000/07/17 23:49:35 1.5 +++ ap_mmap_buf.c 2000/07/18 00:32:31 1.6 @@ -62,7 +62,7 @@ static const char * mmap_get_str(ap_bucket *e) { ap_bucket_mmap *b = (ap_bucket_mmap *)e->data; - return b->data->mm; + return b->alloc_addr; } static int mmap_get_len(ap_bucket *e) @@ -75,14 +75,33 @@ ap_size_t nbytes, ap_ssize_t *w) { ap_bucket_mmap *b = (ap_bucket_mmap *)e->data; - const ap_mmap_t *mm = buf; + ap_mmap_t *mm = (ap_mmap_t *)buf; - b->data = mm; + b->alloc_addr = mm->mm;; b->len = nbytes; *w = nbytes; return APR_SUCCESS; } +static ap_status_t mmap_split(ap_bucket *e, ap_size_t nbyte) +{ + ap_bucket *newbuck; + ap_bucket_mmap *a = (ap_bucket_mmap *)e->data; + ap_bucket_mmap *b; + + newbuck = ap_bucket_new(AP_BUCKET_mmap); + b = (ap_bucket_mmap *)newbuck->data; + a->alloc_addr = a->alloc_addr + nbyte; + a->len = b->len - nbyte; + + a->len = nbyte; + + newbuck->prev = e; + newbuck->next = e->next; + e->next = newbuck; + + return APR_SUCCESS; +} APR_EXPORT(ap_bucket *) ap_mmap_bucket_create(void) { @@ -92,13 +111,14 @@ newbuf = calloc(1, sizeof(*newbuf)); b = malloc(sizeof(*b)); - b->data = NULL; - b->len = 0; + b->alloc_addr = NULL; + b->len = 0; newbuf->color = AP_BUCKET_mmap; newbuf->getstr = mmap_get_str; newbuf->getlen = mmap_get_len; newbuf->insert = mmap_bucket_insert; + newbuf->split = mmap_split; newbuf->free = NULL; newbuf->data = b; 1.7 +24 -0 apache-2.0/src/lib/apr/buckets/ap_rmem_buf.c Index: ap_rmem_buf.c =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/buckets/ap_rmem_buf.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- ap_rmem_buf.c 2000/07/17 23:49:35 1.6 +++ ap_rmem_buf.c 2000/07/18 00:32:31 1.7 @@ -75,6 +75,29 @@ return (char *)b->end - (char *)b->start; } +static ap_status_t rmem_split(ap_bucket *e, ap_size_t nbyte) +{ + ap_bucket *newbuck; + ap_bucket_rmem *a = (ap_bucket_rmem *)e->data; + ap_bucket_rmem *b; + + newbuck = ap_bucket_new(AP_BUCKET_rmem); + b = (ap_bucket_rmem *)newbuck->data; + + b->alloc_len = a->alloc_len - nbyte; + a->alloc_len = nbyte; + b->end = a->end; + a->end = a->start + nbyte; + b->start = a->end + 1; + + newbuck->prev = e; + newbuck->next = e->next; + e->next = newbuck; + + + return APR_SUCCESS; +} + /* * save nbyte bytes to the bucket. * Only returns fewer than nbyte if an error ocurred. @@ -116,6 +139,7 @@ newbuf->getstr = rmem_get_str; newbuf->getlen = rmem_get_len; newbuf->insert = rmem_insert; + newbuf->split = rmem_split; newbuf->free = NULL; newbuf->data = b; return newbuf; 1.7 +23 -0 apache-2.0/src/lib/apr/buckets/ap_rwmem_buf.c Index: ap_rwmem_buf.c =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/buckets/ap_rwmem_buf.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- ap_rwmem_buf.c 2000/07/17 23:49:35 1.6 +++ ap_rwmem_buf.c 2000/07/18 00:32:31 1.7 @@ -81,6 +81,28 @@ free(d->alloc_addr); } +static ap_status_t rwmem_split(ap_bucket *e, ap_size_t nbyte) +{ + ap_bucket *newbuck; + ap_bucket_rwmem *a = (ap_bucket_rwmem *)e; + ap_bucket_rwmem *b; + + newbuck = ap_bucket_new(AP_BUCKET_rwmem); + b = (ap_bucket_rwmem *)newbuck; + + b->alloc_addr = a->alloc_addr; + b->alloc_len = a->alloc_len; + b->end = a->end; + a->end = a->start + nbyte; + b->start = a->end + 1; + + newbuck->prev = e; + newbuck->next = e->next; + e->next = newbuck; + + return APR_SUCCESS; +} + /* * save nbyte bytes to the bucket. * Only returns fewer than nbyte if an error occurred. @@ -136,6 +158,7 @@ newbuf->getstr = rwmem_get_str; newbuf->getlen = rwmem_get_len; newbuf->insert = rwmem_insert; + newbuf->split = rwmem_split; newbuf->free = rwmem_destroy; newbuf->data = b; 1.15 +3 -1 apache-2.0/src/lib/apr/buckets/apr_buf.h Index: apr_buf.h =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/buckets/apr_buf.h,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- apr_buf.h 2000/07/17 23:49:35 1.14 +++ apr_buf.h 2000/07/18 00:32:31 1.15 @@ -95,6 +95,8 @@ * into the bucket. */ int (*insert)(ap_bucket *e, const void *buf, ap_size_t nbytes, ap_ssize_t *w); + ap_status_t (*split)(ap_bucket *e, ap_size_t nbytes); + ap_bucket *next; /* The next node in the bucket list */ ap_bucket *prev; /* The prev node in the bucket list */ }; @@ -131,7 +133,7 @@ typedef struct ap_bucket_mmap ap_bucket_mmap; struct ap_bucket_mmap { - const ap_mmap_t *data; + void *alloc_addr; /* Where does the mmap start? */ int len; /* The amount of data in the mmap that we are * referencing with this bucket. This may be * smaller than the length in the data object,