You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by rb...@locus.apache.org on 2000/07/13 17:10:06 UTC
cvs commit: apache-2.0/src/lib/apr/buckets ap_buf.c apr_buf.h
rbb 00/07/13 08:10:05
Modified: src/lib/apr/buckets ap_buf.c apr_buf.h
Log:
Add ap_bucket_brigade_append_list and ap_bucket_brigade_append_bucket
functions. These add either a list or a bucket to the end of a bucket
brigade.
Also, remove ap_bucket_list_init. This is no longer needed.
Submitted by: Cliff Woolley <jw...@wlu.edu>
Reviewed by: Ryan Bloom
Revision Changes Path
1.10 +34 -33 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.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- ap_buf.c 2000/07/12 23:24:32 1.9
+++ ap_buf.c 2000/07/13 15:10:05 1.10
@@ -137,19 +137,42 @@
return b;
}
-APR_EXPORT(void) ap_bucket_list_init(ap_bucket_list *b)
+APR_EXPORT(void) ap_bucket_brigade_append_list(ap_bucket_brigade *b,
+ ap_bucket_list *e)
{
- b->bucket = NULL;
- b->next = b->prev = NULL;
+ ap_bucket_list *cur = e;
+
+ if (b->tail) {
+ b->tail->next = e;
+ e->prev = b->tail;
+ while (cur->next) {
+ cur = cur->next;
+ }
+ b->tail = cur;
+ }
+ else {
+ b->head = b->tail = e;
+ }
}
-APR_EXPORT(void) ap_bucket_brigade_append(ap_bucket_brigade *b,
- ap_bucket_list *e)
+APR_EXPORT(void) ap_bucket_brigade_append_bucket(ap_bucket_brigade *b,
+ ap_bucket *r)
{
- e->next = b->tail;
- b->tail->prev = e;
- /* This doesn't actually work */
- b->tail = e->next;
+ if (b->tail) {
+ if (b->tail->bucket == NULL) {
+ b->tail->bucket = r;
+ }
+ else {
+ b->tail->next = ap_bucket_list_create();
+ b->tail->next->prev = b->tail;
+ b->tail = b->tail->next;
+ b->tail->bucket = r;
+ }
+ }
+ else {
+ b->head = b->tail = ap_bucket_list_create();
+ b->tail->bucket = r;
+ }
}
APR_EXPORT(int) ap_bucket_brigade_to_iovec(ap_bucket_brigade *b,
@@ -316,18 +339,7 @@
}
k += i;
- /* This really requires an API. Basically we are just adding
- * a bucket to a bucket list.
- */
- if (b->tail->bucket == NULL) {
- b->tail->bucket = r;
- }
- else {
- b->tail->next = ap_bucket_list_create();
- b->tail->next->prev = b->tail;
- b->tail = b->tail->next;
- b->tail->bucket = r;
- }
+ ap_bucket_brigade_append_bucket(b, r);
}
return k;
@@ -357,19 +369,8 @@
r = ap_bucket_new(AP_BUCKET_rwmem);
res = ap_rwmem_write(r->data, buf, strlen(buf), &i);
+ ap_bucket_brigade_append_bucket(b, r);
- /* This really requires an API. Basically we are just adding
- * a bucket to a bucket list.
- */
- if (b->tail->bucket == NULL) {
- b->tail->bucket = r;
- }
- else {
- b->tail->next = ap_bucket_list_create();
- b->tail->next->prev = b->tail;
- b->tail = b->tail->next;
- b->tail->bucket = r;
- }
return res;
}
1.10 +10 -9 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.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- apr_buf.h 2000/07/12 22:12:49 1.9
+++ apr_buf.h 2000/07/13 15:10:05 1.10
@@ -82,15 +82,15 @@
typedef struct ap_bucket ap_bucket;
struct ap_bucket {
ap_bucket_color_e color; /* what type of bucket is it */
- void (*free)(void *e); /* never NULL */
+ void (*free)(void *e); /* can be NULL */
void *data; /* for use by free() */
};
typedef struct ap_bucket_list ap_bucket_list;
struct ap_bucket_list {
ap_bucket *bucket; /* The bucket */
- ap_bucket_list *next; /* The start of the bucket list */
- ap_bucket_list *prev; /* The end of the bucket list */
+ ap_bucket_list *next; /* The next node in the bucket list */
+ ap_bucket_list *prev; /* The prev node in the bucket list */
};
typedef struct ap_bucket_brigade ap_bucket_brigade;
@@ -112,9 +112,13 @@
/* destroy an enitre bucket brigade */
APR_EXPORT(ap_status_t) ap_bucket_brigade_destroy(void *b);
-/* append a bucket_brigade to a bucket_brigade */
-APR_EXPORT(void) ap_bucket_brigade_append(ap_bucket_brigade *b,
- ap_bucket_list *e);
+/* append a bucket_list to a bucket_brigade */
+APR_EXPORT(void) ap_bucket_brigade_append_list(ap_bucket_brigade *b,
+ ap_bucket_list *e);
+
+/* append a bucket to a bucket_brigade */
+APR_EXPORT(void) ap_bucket_brigade_append_bucket(ap_bucket_brigade *b,
+ ap_bucket *r);
/* consume nbytes from beginning of b -- call ap_bucket_destroy as
appropriate, and/or modify start on last element */
@@ -149,9 +153,6 @@
/* create a new bucket_list */
APR_EXPORT(ap_bucket_list *) ap_bucket_list_create(void);
-
-/* initialize a bucket_list */
-APR_EXPORT(void) ap_bucket_list_init(ap_bucket_list *b);
/* destroy an entire bucket_list */
APR_EXPORT(ap_status_t) ap_destroy_bucket_list(ap_bucket_list *b);