httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r1167310 - /httpd/httpd/trunk/modules/http/byterange_filter.c
Date Fri, 09 Sep 2011 17:44:37 GMT
Author: jim
Date: Fri Sep  9 17:44:37 2011
New Revision: 1167310

URL: http://svn.apache.org/viewvc?rev=1167310&view=rev
Log:
Save creation of merged until we know we will actually need and use it.

Modified:
    httpd/httpd/trunk/modules/http/byterange_filter.c

Modified: httpd/httpd/trunk/modules/http/byterange_filter.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http/byterange_filter.c?rev=1167310&r1=1167309&r2=1167310&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/http/byterange_filter.c (original)
+++ httpd/httpd/trunk/modules/http/byterange_filter.c Fri Sep  9 17:44:37 2011
@@ -79,13 +79,14 @@ static int ap_set_byterange(request_rec 
     const char *if_range;
     const char *match;
     const char *ct;
-    char *cur, **new;
+    char *cur;
     apr_array_header_t *merged;
     int num_ranges = 0, unsatisfiable = 0;
     apr_off_t ostart = 0, oend = 0, sum_lengths = 0;
     int in_merge = 0;
     indexes_t *idx;
     int ranges = 1;
+    int i;
     const char *it;
 
     *overlaps = 0;
@@ -156,7 +157,6 @@ static int ap_set_byterange(request_rec 
         ranges = MAX_PREALLOC_RANGES;
     }
     *indexes = apr_array_make(r->pool, ranges, sizeof(indexes_t));
-    merged = apr_array_make(r->pool, ranges, sizeof(char *));
     while ((cur = ap_getword(r->pool, &range, ','))) {
         char *dash;
         char *errp;
@@ -243,9 +243,6 @@ static int ap_set_byterange(request_rec 
             ++*overlaps;
             continue;
         } else {
-            new = (char **)apr_array_push(merged);
-            *new = apr_psprintf(r->pool, "%" APR_OFF_T_FMT "-%" APR_OFF_T_FMT,
-                                ostart, oend);
             idx = (indexes_t *)apr_array_push(*indexes);
             idx->start = ostart;
             idx->end = oend;
@@ -259,9 +256,6 @@ static int ap_set_byterange(request_rec 
     }
     
     if (in_merge) {
-        new = (char **)apr_array_push(merged);
-        *new = apr_psprintf(r->pool, "%" APR_OFF_T_FMT "-%" APR_OFF_T_FMT,
-                            ostart, oend);
         idx = (indexes_t *)apr_array_push(*indexes);
         idx->start = ostart;
         idx->end = oend;
@@ -277,7 +271,18 @@ static int ap_set_byterange(request_rec 
                       "Sum of ranges not smaller than file, ignoring.");
         return 0;
     }
-    
+
+    /*
+     * create the merged table now, now that we know we need it
+     */
+    merged = apr_array_make(r->pool, num_ranges, sizeof(char *));
+    idx = (indexes_t *)(*indexes)->elts;
+    for (i = 0; i < (*indexes)->nelts; i++, idx++) {
+        char **new = (char **)apr_array_push(merged);
+        *new = apr_psprintf(r->pool, "%" APR_OFF_T_FMT "-%" APR_OFF_T_FMT,
+                            idx->start, idx->end);
+    }
+
     r->status = HTTP_PARTIAL_CONTENT;
     r->range = apr_array_pstrcat(r->pool, merged, ',');
     ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,



Mime
View raw message