From: Stefan Fritsch Date: Mon, 13 Jun 2011 10:58:10 +0000 (+0000) Subject: Avoid some memory allocations by using apr_table_setn where the string X-Git-Tag: 2.3.13~59 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f66af00c190209b66437454835eb433553edce0e;p=thirdparty%2Fapache%2Fhttpd.git Avoid some memory allocations by using apr_table_setn where the string arguments are const. Submitted by: Christophe JAILLET PR: 51357 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1135083 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/arch/netware/mod_netware.c b/modules/arch/netware/mod_netware.c index 76954cf6fb8..ad497292dee 100644 --- a/modules/arch/netware/mod_netware.c +++ b/modules/arch/netware/mod_netware.c @@ -51,7 +51,7 @@ static void *create_netware_dir_config(apr_pool_t *p, char *dir) new->file_handler_mode = apr_table_make(p, 10); new->extra_env_vars = apr_table_make(p, 10); - apr_table_set(new->file_type_handlers, "NLM", "OS"); + apr_table_setn(new->file_type_handlers, "NLM", "OS"); return new; } diff --git a/modules/arch/netware/mod_nw_ssl.c b/modules/arch/netware/mod_nw_ssl.c index 2750a17d766..bc7665617a9 100644 --- a/modules/arch/netware/mod_nw_ssl.c +++ b/modules/arch/netware/mod_nw_ssl.c @@ -895,7 +895,7 @@ static int nwssl_hook_Fixup(request_rec *r) if (!isSecure(r) && !isSecureUpgraded(r)) return DECLINED; - apr_table_set(r->subprocess_env, "HTTPS", "on"); + apr_table_setn(r->subprocess_env, "HTTPS", "on"); return DECLINED; } @@ -918,7 +918,7 @@ static apr_port_t nwssl_hook_default_port(const request_rec *r) int ssl_proxy_enable(conn_rec *c) { - apr_table_set(c->notes, "nwconv-ssl", "Y"); + apr_table_setn(c->notes, "nwconv-ssl", "Y"); return 1; } diff --git a/modules/cache/cache_util.c b/modules/cache/cache_util.c index d359f0a8d4f..a735cef274d 100644 --- a/modules/cache/cache_util.c +++ b/modules/cache/cache_util.c @@ -644,8 +644,8 @@ int cache_check_freshness(cache_handle_t *h, cache_request_rec *cache, /* make sure we don't stomp on a previous warning */ if ((warn_head == NULL) || ((warn_head != NULL) && (ap_strstr_c(warn_head, "110") == NULL))) { - apr_table_merge(h->resp_hdrs, "Warning", - "110 Response is stale"); + apr_table_mergen(h->resp_hdrs, "Warning", + "110 Response is stale"); } } @@ -663,8 +663,8 @@ int cache_check_freshness(cache_handle_t *h, cache_request_rec *cache, */ if ((warn_head == NULL) || ((warn_head != NULL) && (ap_strstr_c(warn_head, "113") == NULL))) { - apr_table_merge(h->resp_hdrs, "Warning", - "113 Heuristic expiration"); + apr_table_mergen(h->resp_hdrs, "Warning", + "113 Heuristic expiration"); } } return 1; /* Cache object is fresh (enough) */ @@ -720,8 +720,8 @@ int cache_check_freshness(cache_handle_t *h, cache_request_rec *cache, warn_head = apr_table_get(h->resp_hdrs, "Warning"); if ((warn_head == NULL) || ((warn_head != NULL) && (ap_strstr_c(warn_head, "110") == NULL))) { - apr_table_merge(h->resp_hdrs, "Warning", - "110 Response is stale"); + apr_table_mergen(h->resp_hdrs, "Warning", + "110 Response is stale"); } return 1; diff --git a/modules/http/http_filters.c b/modules/http/http_filters.c index d4aa068605d..a42a3bb16d8 100644 --- a/modules/http/http_filters.c +++ b/modules/http/http_filters.c @@ -1211,7 +1211,7 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_http_header_filter(ap_filter_t *f, if (apr_table_get(r->subprocess_env, "force-no-vary") != NULL) { apr_table_unset(r->headers_out, "Vary"); r->proto_num = HTTP_VERSION(1,0); - apr_table_set(r->subprocess_env, "force-response-1.0", "1"); + apr_table_setn(r->subprocess_env, "force-response-1.0", "1"); } else { fixup_vary(r); diff --git a/modules/proxy/proxy_util.c b/modules/proxy/proxy_util.c index e79d84bfdb6..27d774cbe80 100644 --- a/modules/proxy/proxy_util.c +++ b/modules/proxy/proxy_util.c @@ -2008,7 +2008,7 @@ PROXY_DECLARE(int) ap_proxy_pre_request(proxy_worker **worker, * ensure that mod_proxy_http does the correct thing * regarding the Connection header in the request. */ - apr_table_set(r->subprocess_env, "proxy-nokeepalive", "1"); + apr_table_setn(r->subprocess_env, "proxy-nokeepalive", "1"); } } else if (r->proxyreq == PROXYREQ_REVERSE) { @@ -2024,7 +2024,7 @@ PROXY_DECLARE(int) ap_proxy_pre_request(proxy_worker **worker, * ensure that mod_proxy_http does the correct thing * regarding the Connection header in the request. */ - apr_table_set(r->subprocess_env, "proxy-nokeepalive", "1"); + apr_table_setn(r->subprocess_env, "proxy-nokeepalive", "1"); } } } diff --git a/modules/ssl/ssl_engine_io.c b/modules/ssl/ssl_engine_io.c index 4693ea4308d..bb2933a15cf 100644 --- a/modules/ssl/ssl_engine_io.c +++ b/modules/ssl/ssl_engine_io.c @@ -1053,7 +1053,7 @@ static apr_status_t ssl_io_filter_handshake(ssl_filter_ctx_t *filter_ctx) ssl_log_ssl_error(SSLLOG_MARK, APLOG_INFO, server); /* ensure that the SSL structures etc are freed, etc: */ ssl_filter_io_shutdown(filter_ctx, c, 1); - apr_table_set(c->notes, "SSL_connect_rv", "err"); + apr_table_setn(c->notes, "SSL_connect_rv", "err"); return MODSSL_ERROR_BAD_GATEWAY; } @@ -1071,7 +1071,7 @@ static apr_status_t ssl_io_filter_handshake(ssl_filter_ctx_t *filter_ctx) } /* ensure that the SSL structures etc are freed, etc: */ ssl_filter_io_shutdown(filter_ctx, c, 1); - apr_table_set(c->notes, "SSL_connect_rv", "err"); + apr_table_setn(c->notes, "SSL_connect_rv", "err"); return HTTP_BAD_GATEWAY; } X509_free(cert); @@ -1091,12 +1091,12 @@ static apr_status_t ssl_io_filter_handshake(ssl_filter_ctx_t *filter_ctx) hostname, hostname_note); /* ensure that the SSL structures etc are freed, etc: */ ssl_filter_io_shutdown(filter_ctx, c, 1); - apr_table_set(c->notes, "SSL_connect_rv", "err"); + apr_table_setn(c->notes, "SSL_connect_rv", "err"); return HTTP_BAD_GATEWAY; } } - apr_table_set(c->notes, "SSL_connect_rv", "ok"); + apr_table_setn(c->notes, "SSL_connect_rv", "ok"); return APR_SUCCESS; }