Return-Path: Mailing-List: contact cvs-help@apr.apache.org; run by ezmlm Delivered-To: mailing list cvs@apr.apache.org Received: (qmail 73910 invoked by uid 500); 29 Dec 2000 14:01:54 -0000 Delivered-To: apmail-apr-util-cvs@apache.org Received: (qmail 73907 invoked by uid 1121); 29 Dec 2000 14:01:53 -0000 Date: 29 Dec 2000 14:01:53 -0000 Message-ID: <20001229140153.73906.qmail@locus.apache.org> From: trawick@locus.apache.org To: apr-util-cvs@apache.org Subject: 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); }