Skip to content

Commit 414b5fe

Browse files
author
Stefan Fritsch
committed
Avoid some memory allocations by using apr_table_setn where the string
arguments are const. Submitted by: Christophe JAILLET <christophe jaillet wanadoo fr> PR: 51357 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1135083 13f79535-47bb-0310-9956-ffa450edef68
1 parent 8f0e8a8 commit 414b5fe

6 files changed

Lines changed: 16 additions & 16 deletions

File tree

modules/arch/netware/mod_netware.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ static void *create_netware_dir_config(apr_pool_t *p, char *dir)
5151
new->file_handler_mode = apr_table_make(p, 10);
5252
new->extra_env_vars = apr_table_make(p, 10);
5353

54-
apr_table_set(new->file_type_handlers, "NLM", "OS");
54+
apr_table_setn(new->file_type_handlers, "NLM", "OS");
5555

5656
return new;
5757
}

modules/arch/netware/mod_nw_ssl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,7 @@ static int nwssl_hook_Fixup(request_rec *r)
895895
if (!isSecure(r) && !isSecureUpgraded(r))
896896
return DECLINED;
897897

898-
apr_table_set(r->subprocess_env, "HTTPS", "on");
898+
apr_table_setn(r->subprocess_env, "HTTPS", "on");
899899

900900
return DECLINED;
901901
}
@@ -918,7 +918,7 @@ static apr_port_t nwssl_hook_default_port(const request_rec *r)
918918

919919
int ssl_proxy_enable(conn_rec *c)
920920
{
921-
apr_table_set(c->notes, "nwconv-ssl", "Y");
921+
apr_table_setn(c->notes, "nwconv-ssl", "Y");
922922

923923
return 1;
924924
}

modules/cache/cache_util.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -644,8 +644,8 @@ int cache_check_freshness(cache_handle_t *h, cache_request_rec *cache,
644644
/* make sure we don't stomp on a previous warning */
645645
if ((warn_head == NULL) ||
646646
((warn_head != NULL) && (ap_strstr_c(warn_head, "110") == NULL))) {
647-
apr_table_merge(h->resp_hdrs, "Warning",
648-
"110 Response is stale");
647+
apr_table_mergen(h->resp_hdrs, "Warning",
648+
"110 Response is stale");
649649
}
650650
}
651651

@@ -663,8 +663,8 @@ int cache_check_freshness(cache_handle_t *h, cache_request_rec *cache,
663663
*/
664664
if ((warn_head == NULL) ||
665665
((warn_head != NULL) && (ap_strstr_c(warn_head, "113") == NULL))) {
666-
apr_table_merge(h->resp_hdrs, "Warning",
667-
"113 Heuristic expiration");
666+
apr_table_mergen(h->resp_hdrs, "Warning",
667+
"113 Heuristic expiration");
668668
}
669669
}
670670
return 1; /* Cache object is fresh (enough) */
@@ -720,8 +720,8 @@ int cache_check_freshness(cache_handle_t *h, cache_request_rec *cache,
720720
warn_head = apr_table_get(h->resp_hdrs, "Warning");
721721
if ((warn_head == NULL) ||
722722
((warn_head != NULL) && (ap_strstr_c(warn_head, "110") == NULL))) {
723-
apr_table_merge(h->resp_hdrs, "Warning",
724-
"110 Response is stale");
723+
apr_table_mergen(h->resp_hdrs, "Warning",
724+
"110 Response is stale");
725725
}
726726

727727
return 1;

modules/http/http_filters.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1211,7 +1211,7 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_http_header_filter(ap_filter_t *f,
12111211
if (apr_table_get(r->subprocess_env, "force-no-vary") != NULL) {
12121212
apr_table_unset(r->headers_out, "Vary");
12131213
r->proto_num = HTTP_VERSION(1,0);
1214-
apr_table_set(r->subprocess_env, "force-response-1.0", "1");
1214+
apr_table_setn(r->subprocess_env, "force-response-1.0", "1");
12151215
}
12161216
else {
12171217
fixup_vary(r);

modules/proxy/proxy_util.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2008,7 +2008,7 @@ PROXY_DECLARE(int) ap_proxy_pre_request(proxy_worker **worker,
20082008
* ensure that mod_proxy_http does the correct thing
20092009
* regarding the Connection header in the request.
20102010
*/
2011-
apr_table_set(r->subprocess_env, "proxy-nokeepalive", "1");
2011+
apr_table_setn(r->subprocess_env, "proxy-nokeepalive", "1");
20122012
}
20132013
}
20142014
else if (r->proxyreq == PROXYREQ_REVERSE) {
@@ -2024,7 +2024,7 @@ PROXY_DECLARE(int) ap_proxy_pre_request(proxy_worker **worker,
20242024
* ensure that mod_proxy_http does the correct thing
20252025
* regarding the Connection header in the request.
20262026
*/
2027-
apr_table_set(r->subprocess_env, "proxy-nokeepalive", "1");
2027+
apr_table_setn(r->subprocess_env, "proxy-nokeepalive", "1");
20282028
}
20292029
}
20302030
}

modules/ssl/ssl_engine_io.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,7 @@ static apr_status_t ssl_io_filter_handshake(ssl_filter_ctx_t *filter_ctx)
10531053
ssl_log_ssl_error(SSLLOG_MARK, APLOG_INFO, server);
10541054
/* ensure that the SSL structures etc are freed, etc: */
10551055
ssl_filter_io_shutdown(filter_ctx, c, 1);
1056-
apr_table_set(c->notes, "SSL_connect_rv", "err");
1056+
apr_table_setn(c->notes, "SSL_connect_rv", "err");
10571057
return MODSSL_ERROR_BAD_GATEWAY;
10581058
}
10591059

@@ -1071,7 +1071,7 @@ static apr_status_t ssl_io_filter_handshake(ssl_filter_ctx_t *filter_ctx)
10711071
}
10721072
/* ensure that the SSL structures etc are freed, etc: */
10731073
ssl_filter_io_shutdown(filter_ctx, c, 1);
1074-
apr_table_set(c->notes, "SSL_connect_rv", "err");
1074+
apr_table_setn(c->notes, "SSL_connect_rv", "err");
10751075
return HTTP_BAD_GATEWAY;
10761076
}
10771077
X509_free(cert);
@@ -1091,12 +1091,12 @@ static apr_status_t ssl_io_filter_handshake(ssl_filter_ctx_t *filter_ctx)
10911091
hostname, hostname_note);
10921092
/* ensure that the SSL structures etc are freed, etc: */
10931093
ssl_filter_io_shutdown(filter_ctx, c, 1);
1094-
apr_table_set(c->notes, "SSL_connect_rv", "err");
1094+
apr_table_setn(c->notes, "SSL_connect_rv", "err");
10951095
return HTTP_BAD_GATEWAY;
10961096
}
10971097
}
10981098

1099-
apr_table_set(c->notes, "SSL_connect_rv", "ok");
1099+
apr_table_setn(c->notes, "SSL_connect_rv", "ok");
11001100
return APR_SUCCESS;
11011101
}
11021102

0 commit comments

Comments
 (0)