summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--buckets/ap_buckets.c4
-rw-r--r--buckets/ap_buckets_heap.c3
-rw-r--r--buckets/ap_buckets_pipe.c25
-rw-r--r--buckets/apr_buckets.c4
-rw-r--r--buckets/apr_buckets_heap.c3
-rw-r--r--buckets/apr_buckets_pipe.c25
-rw-r--r--include/ap_buckets.h3
-rw-r--r--include/apr_buckets.h3
-rw-r--r--src/buckets/ap_buckets.c4
-rw-r--r--src/buckets/ap_buckets_heap.c3
-rw-r--r--src/buckets/ap_buckets_pipe.c25
11 files changed, 49 insertions, 53 deletions
diff --git a/buckets/ap_buckets.c b/buckets/ap_buckets.c
index c53c2044..656fdb07 100644
--- a/buckets/ap_buckets.c
+++ b/buckets/ap_buckets.c
@@ -208,11 +208,11 @@ API_EXPORT(int) ap_brigade_vprintf(ap_bucket_brigade *b, const char *fmt, va_lis
*/
char buf[4096];
ap_bucket *r;
- int res, i;
+ int res;
res = apr_vsnprintf(buf, 4096, fmt, va);
- r = ap_bucket_create_heap(buf, strlen(buf), 1, &i);
+ r = ap_bucket_create_heap(buf, strlen(buf), 1, NULL);
ap_brigade_append_buckets(b, r);
return res;
diff --git a/buckets/ap_buckets_heap.c b/buckets/ap_buckets_heap.c
index c8fc48f0..29e3c57f 100644
--- a/buckets/ap_buckets_heap.c
+++ b/buckets/ap_buckets_heap.c
@@ -133,7 +133,8 @@ API_EXPORT(ap_bucket *) ap_bucket_make_heap(ap_bucket *b,
b->read = heap_read;
b->setaside = NULL;
- *w = length;
+ if (w)
+ *w = length;
return b;
}
diff --git a/buckets/ap_buckets_pipe.c b/buckets/ap_buckets_pipe.c
index ab827e22..8e0d08ac 100644
--- a/buckets/ap_buckets_pipe.c
+++ b/buckets/ap_buckets_pipe.c
@@ -67,31 +67,28 @@ static apr_status_t pipe_split(ap_bucket *a, apr_off_t point)
}
/* Ignore the block arg for now. We can fix that tomorrow. */
-static apr_status_t pipe_read(ap_bucket *b, const char **str,
+static apr_status_t pipe_read(ap_bucket *b, const char **str,
apr_ssize_t *len, int block)
{
ap_bucket_pipe *bd = b->data;
ap_bucket *a;
- apr_size_t l;
- apr_ssize_t toss;
- char buf[IOBUFSIZE];
+ char *buf;
apr_status_t rv;
+ /*
+ * XXX: We need to obey the block flag
+ */
+ buf = malloc(IOBUFSIZE);
+ *str = buf;
*len = IOBUFSIZE;
if ((rv = apr_read(bd->thepipe, buf, len)) != APR_SUCCESS) {
+ free(buf);
return rv;
}
- if (*len > 0) {
- l = *len;
+ if (len > 0) {
a = ap_bucket_create_pipe(bd->thepipe);
-
- /* XXX ap_bucket_make_heap() can decide not to copy all our data;
- * either handle it here or ensure that IOBUFSIZE <
- * DEFAULT_BUCKET_SIZE;
- */
- b = ap_bucket_make_heap(b, buf, l, 1, &toss);
- b->read(b, str, len, block); /* set str to new location of data */
-
+ b = ap_bucket_make_heap(b, buf, *len, 0, NULL);
+
if (b->next) {
b->next->prev = a;
}
diff --git a/buckets/apr_buckets.c b/buckets/apr_buckets.c
index c53c2044..656fdb07 100644
--- a/buckets/apr_buckets.c
+++ b/buckets/apr_buckets.c
@@ -208,11 +208,11 @@ API_EXPORT(int) ap_brigade_vprintf(ap_bucket_brigade *b, const char *fmt, va_lis
*/
char buf[4096];
ap_bucket *r;
- int res, i;
+ int res;
res = apr_vsnprintf(buf, 4096, fmt, va);
- r = ap_bucket_create_heap(buf, strlen(buf), 1, &i);
+ r = ap_bucket_create_heap(buf, strlen(buf), 1, NULL);
ap_brigade_append_buckets(b, r);
return res;
diff --git a/buckets/apr_buckets_heap.c b/buckets/apr_buckets_heap.c
index c8fc48f0..29e3c57f 100644
--- a/buckets/apr_buckets_heap.c
+++ b/buckets/apr_buckets_heap.c
@@ -133,7 +133,8 @@ API_EXPORT(ap_bucket *) ap_bucket_make_heap(ap_bucket *b,
b->read = heap_read;
b->setaside = NULL;
- *w = length;
+ if (w)
+ *w = length;
return b;
}
diff --git a/buckets/apr_buckets_pipe.c b/buckets/apr_buckets_pipe.c
index ab827e22..8e0d08ac 100644
--- a/buckets/apr_buckets_pipe.c
+++ b/buckets/apr_buckets_pipe.c
@@ -67,31 +67,28 @@ static apr_status_t pipe_split(ap_bucket *a, apr_off_t point)
}
/* Ignore the block arg for now. We can fix that tomorrow. */
-static apr_status_t pipe_read(ap_bucket *b, const char **str,
+static apr_status_t pipe_read(ap_bucket *b, const char **str,
apr_ssize_t *len, int block)
{
ap_bucket_pipe *bd = b->data;
ap_bucket *a;
- apr_size_t l;
- apr_ssize_t toss;
- char buf[IOBUFSIZE];
+ char *buf;
apr_status_t rv;
+ /*
+ * XXX: We need to obey the block flag
+ */
+ buf = malloc(IOBUFSIZE);
+ *str = buf;
*len = IOBUFSIZE;
if ((rv = apr_read(bd->thepipe, buf, len)) != APR_SUCCESS) {
+ free(buf);
return rv;
}
- if (*len > 0) {
- l = *len;
+ if (len > 0) {
a = ap_bucket_create_pipe(bd->thepipe);
-
- /* XXX ap_bucket_make_heap() can decide not to copy all our data;
- * either handle it here or ensure that IOBUFSIZE <
- * DEFAULT_BUCKET_SIZE;
- */
- b = ap_bucket_make_heap(b, buf, l, 1, &toss);
- b->read(b, str, len, block); /* set str to new location of data */
-
+ b = ap_bucket_make_heap(b, buf, *len, 0, NULL);
+
if (b->next) {
b->next->prev = a;
}
diff --git a/include/ap_buckets.h b/include/ap_buckets.h
index 7c46a46c..9293f318 100644
--- a/include/ap_buckets.h
+++ b/include/ap_buckets.h
@@ -540,7 +540,8 @@ API_EXPORT(ap_bucket *) ap_bucket_make_transient(ap_bucket *b,
* @param buf The buffer to insert into the bucket
* @param nbyte The size of the buffer to insert.
* @param copy Whether to copy the data into newly-allocated memory or not
- * @param w The number of bytes actually copied into the bucket
+ * @param w The number of bytes actually copied into the bucket.
+ * If copy is zero then this return value can be ignored by passing a NULL pointer.
* @return The new bucket, or NULL if allocation failed
* @deffunc ap_bucket *ap_bucket_create_heap(const char *buf, apr_size_t nbyte, apr_ssize_t *w)
*/
diff --git a/include/apr_buckets.h b/include/apr_buckets.h
index 7c46a46c..9293f318 100644
--- a/include/apr_buckets.h
+++ b/include/apr_buckets.h
@@ -540,7 +540,8 @@ API_EXPORT(ap_bucket *) ap_bucket_make_transient(ap_bucket *b,
* @param buf The buffer to insert into the bucket
* @param nbyte The size of the buffer to insert.
* @param copy Whether to copy the data into newly-allocated memory or not
- * @param w The number of bytes actually copied into the bucket
+ * @param w The number of bytes actually copied into the bucket.
+ * If copy is zero then this return value can be ignored by passing a NULL pointer.
* @return The new bucket, or NULL if allocation failed
* @deffunc ap_bucket *ap_bucket_create_heap(const char *buf, apr_size_t nbyte, apr_ssize_t *w)
*/
diff --git a/src/buckets/ap_buckets.c b/src/buckets/ap_buckets.c
index c53c2044..656fdb07 100644
--- a/src/buckets/ap_buckets.c
+++ b/src/buckets/ap_buckets.c
@@ -208,11 +208,11 @@ API_EXPORT(int) ap_brigade_vprintf(ap_bucket_brigade *b, const char *fmt, va_lis
*/
char buf[4096];
ap_bucket *r;
- int res, i;
+ int res;
res = apr_vsnprintf(buf, 4096, fmt, va);
- r = ap_bucket_create_heap(buf, strlen(buf), 1, &i);
+ r = ap_bucket_create_heap(buf, strlen(buf), 1, NULL);
ap_brigade_append_buckets(b, r);
return res;
diff --git a/src/buckets/ap_buckets_heap.c b/src/buckets/ap_buckets_heap.c
index c8fc48f0..29e3c57f 100644
--- a/src/buckets/ap_buckets_heap.c
+++ b/src/buckets/ap_buckets_heap.c
@@ -133,7 +133,8 @@ API_EXPORT(ap_bucket *) ap_bucket_make_heap(ap_bucket *b,
b->read = heap_read;
b->setaside = NULL;
- *w = length;
+ if (w)
+ *w = length;
return b;
}
diff --git a/src/buckets/ap_buckets_pipe.c b/src/buckets/ap_buckets_pipe.c
index ab827e22..8e0d08ac 100644
--- a/src/buckets/ap_buckets_pipe.c
+++ b/src/buckets/ap_buckets_pipe.c
@@ -67,31 +67,28 @@ static apr_status_t pipe_split(ap_bucket *a, apr_off_t point)
}
/* Ignore the block arg for now. We can fix that tomorrow. */
-static apr_status_t pipe_read(ap_bucket *b, const char **str,
+static apr_status_t pipe_read(ap_bucket *b, const char **str,
apr_ssize_t *len, int block)
{
ap_bucket_pipe *bd = b->data;
ap_bucket *a;
- apr_size_t l;
- apr_ssize_t toss;
- char buf[IOBUFSIZE];
+ char *buf;
apr_status_t rv;
+ /*
+ * XXX: We need to obey the block flag
+ */
+ buf = malloc(IOBUFSIZE);
+ *str = buf;
*len = IOBUFSIZE;
if ((rv = apr_read(bd->thepipe, buf, len)) != APR_SUCCESS) {
+ free(buf);
return rv;
}
- if (*len > 0) {
- l = *len;
+ if (len > 0) {
a = ap_bucket_create_pipe(bd->thepipe);
-
- /* XXX ap_bucket_make_heap() can decide not to copy all our data;
- * either handle it here or ensure that IOBUFSIZE <
- * DEFAULT_BUCKET_SIZE;
- */
- b = ap_bucket_make_heap(b, buf, l, 1, &toss);
- b->read(b, str, len, block); /* set str to new location of data */
-
+ b = ap_bucket_make_heap(b, buf, *len, 0, NULL);
+
if (b->next) {
b->next->prev = a;
}