You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by tr...@locus.apache.org on 2000/12/29 15:01:53 UTC
cvs commit: apr-util/src/buckets ap_buckets_heap.c
trawick 00/12/29 06:01:53
Modified: src/buckets ap_buckets_heap.c
Log:
ap_bucket_make_heap() now works in copy mode when the input bucket is
larger than DEFAULT_BUCKET_SIZE. Previously, it silently ignored (lost)
any bytes beyond DEFAULT_BUCKET_SIZE.
Revision Changes Path
1.22 +7 -5 apr-util/src/buckets/ap_buckets_heap.c
Index: ap_buckets_heap.c
===================================================================
RCS file: /home/cvs/apr-util/src/buckets/ap_buckets_heap.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- ap_buckets_heap.c 2000/12/22 16:54:58 1.21
+++ ap_buckets_heap.c 2000/12/29 14:01:52 1.22
@@ -67,6 +67,11 @@
#define DEFAULT_BUCKET_SIZE (4096)
#endif
+#ifndef max
+#define max(x,y) \
+((x) >= (y) ? (x) : (y))
+#endif
+
static apr_status_t heap_read(ap_bucket *b, const char **str,
apr_size_t *len, ap_read_type block)
{
@@ -101,14 +106,11 @@
}
if (copy) {
- h->base = malloc(DEFAULT_BUCKET_SIZE);
+ h->alloc_len = max(DEFAULT_BUCKET_SIZE, length);
+ h->base = malloc(h->alloc_len);
if (h->base == NULL) {
free(h);
return NULL;
- }
- h->alloc_len = DEFAULT_BUCKET_SIZE;
- if (length > DEFAULT_BUCKET_SIZE) {
- length = DEFAULT_BUCKET_SIZE;
}
memcpy(h->base, buf, length);
}