Avoid some memory allocations by using apr_table_setn where the string arguments
authorStefan Fritsch <sf@apache.org>
Mon, 13 Jun 2011 11:04:29 +0000 (11:04 +0000)
committerStefan Fritsch <sf@apache.org>
Mon, 13 Jun 2011 11:04:29 +0000 (11:04 +0000)
are allocated from the request pool and not modified later on.

Submitted by: Christophe JAILLET <christophe jaillet wanadoo fr>
PR: 51358

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1135084 13f79535-47bb-0310-9956-ffa450edef68

modules/aaa/mod_auth_form.c
modules/dav/main/mod_dav.c
modules/mappers/mod_rewrite.c
modules/proxy/mod_proxy.c
modules/proxy/mod_proxy_ftp.c
modules/ssl/ssl_engine_kernel.c

index 41e1f2fe369418c45a2519a117a230fcb0ed1bcc..c713aac20b5101144b401ddccd65a49bb9f43601 100644 (file)
@@ -832,8 +832,8 @@ static void fake_basic_authentication(request_rec *r, auth_form_config_rec *conf
         char *base64 = apr_palloc(r->pool,
                                   apr_base64_encode_len(size + 1) * sizeof(char));
         apr_base64_encode(base64, basic, size);
-        apr_table_set(r->headers_in, "Authorization",
-                      apr_pstrcat(r->pool, "Basic ", base64, NULL));
+        apr_table_setn(r->headers_in, "Authorization",
+                       apr_pstrcat(r->pool, "Basic ", base64, NULL));
     }
 }
 
index 1b18cb28330c3f78930ae5e93fb939efd627e36b..d021b91e16e220e1d87e41b29f3f0bb461e8115d 100644 (file)
@@ -2667,8 +2667,8 @@ static int dav_method_copymove(request_rec *r, int is_move)
         if (lookup.rnew->status == HTTP_UNAUTHORIZED && auth != NULL) {
             /* propagate the WWW-Authorization header up from the
              * subreq so the client sees it. */
-            apr_table_set(r->err_headers_out, "WWW-Authenticate",
-                          apr_pstrdup(r->pool, auth));
+            apr_table_setn(r->err_headers_out, "WWW-Authenticate",
+                           apr_pstrdup(r->pool, auth));
         }
 
         /* ### how best to report this... */
@@ -3148,7 +3148,7 @@ static int dav_method_lock(request_rec *r)
                                         lock->locktoken),
                                     ">", NULL);
 
-        apr_table_set(r->headers_out, "Lock-Token", locktoken_txt);
+        apr_table_setn(r->headers_out, "Lock-Token", locktoken_txt);
     }
 
     (*locks_hooks->close_lockdb)(lockdb);
index 32def93669a3741ffbae122d7cad61c0917cb6f0..c090959383e146eb49bec819bc1f7897c67f8e8e 100644 (file)
@@ -4482,8 +4482,8 @@ static int hook_uri2file(request_rec *r)
          *  now apply the rules ...
          */
         rulestatus = apply_rewrite_list(r, conf->rewriterules, NULL);
-        apr_table_set(r->notes,"mod_rewrite_rewritten",
-                      apr_psprintf(r->pool,"%d",rulestatus));
+        apr_table_setn(r->notes, "mod_rewrite_rewritten",
+                       apr_psprintf(r->pool,"%d",rulestatus));
     }
     else {
         rewritelog((r, 2, NULL, "uri already rewritten. Status %s, Uri %s, "
index 10cd577da307c3f3029c70b4d552f1c0fd9c347a..29802dc12923fed28824441fbab9844087555fb0 100644 (file)
@@ -880,8 +880,8 @@ static int proxy_handler(request_rec *r)
         maxfwd = conf->maxfwd;
     }
     if (maxfwd >= 0) {
-        apr_table_set(r->headers_in, "Max-Forwards",
-                      apr_psprintf(r->pool, "%ld", maxfwd));
+        apr_table_setn(r->headers_in, "Max-Forwards",
+                       apr_psprintf(r->pool, "%ld", maxfwd));
     }
 
     if (r->method_number == M_TRACE) {
index e9ddb6105adb4767ae71ea1c5d342d62ba05c195..20622be90c1624cc598fa42ed87ec02088959868 100644 (file)
@@ -1165,8 +1165,8 @@ static int proxy_ftp_handler(request_rec *r, proxy_worker *worker,
                 break;
         if (*secs_str != '\0') {
             secs = atol(secs_str);
-            apr_table_add(r->headers_out, "Retry-After",
-                          apr_psprintf(p, "%lu", (unsigned long)(60 * secs)));
+            apr_table_addn(r->headers_out, "Retry-After",
+                           apr_psprintf(p, "%lu", (unsigned long)(60 * secs)));
         }
         return ftp_proxyerror(r, backend, HTTP_SERVICE_UNAVAILABLE, ftpmessage);
     }
index 3bb5846d76496703daf3b556c612e1ecb9fdc2ad..1ff5d2e63b2f751157ff174dca1edd6e2f886c77 100644 (file)
@@ -1042,7 +1042,7 @@ int ssl_hook_UserCheck(request_rec *r)
                                              apr_pstrcat(r->pool, clientdn,
                                                          ":password", NULL)),
                             NULL);
-    apr_table_set(r->headers_in, "Authorization", auth_line);
+    apr_table_setn(r->headers_in, "Authorization", auth_line);
 
     ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r,
                   "Faking HTTP Basic Auth header: \"Authorization: %s\"",