Constify pointers in ap_expr lookup tables, as well as the already

const pointed-to strings.  ~1/2Kb moves to r/o text section, size(1)
diff:

    text           data     bss     dec     hex filename
- 667519          18384   13952  699855   aadcf httpd
+ 668015          17864   13952  699831   aadb7 httpd

* server/util_expr_eval.c
  [*_var_names, expr_provider_multi]: Mark pointers in name
  lists as const.
  (core_expr_lookup): Adjust accordingly.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1877350 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Joe Orton
2020-05-04 10:48:55 +00:00
parent ccc38eab46
commit 58c4c85ff7

View File

@ -1634,7 +1634,7 @@ static APR_OPTIONAL_FN_TYPE(ssl_is_https) *is_https = NULL;
APR_DECLARE_OPTIONAL_FN(int, http2_is_h2, (conn_rec *));
static APR_OPTIONAL_FN_TYPE(http2_is_h2) *is_http2 = NULL;
static const char *conn_var_names[] = {
static const char *const conn_var_names[] = {
"HTTPS", /* 0 */
"IPV6", /* 1 */
"CONN_LOG_ID", /* 2 */
@ -1684,7 +1684,7 @@ static const char *conn_var_fn(ap_expr_eval_ctx_t *ctx, const void *data)
}
}
static const char *request_var_names[] = {
static const char *const request_var_names[] = {
"REQUEST_METHOD", /* 0 */
"REQUEST_SCHEME", /* 1 */
"REQUEST_URI", /* 2 */
@ -1835,7 +1835,7 @@ static const char *request_var_fn(ap_expr_eval_ctx_t *ctx, const void *data)
}
}
static const char *req_header_var_names[] = {
static const char *const req_header_var_names[] = {
"HTTP_USER_AGENT", /* 0 */
"HTTP_PROXY_CONNECTION", /* 1 */
"HTTP_REFERER", /* 2 */
@ -1846,7 +1846,7 @@ static const char *req_header_var_names[] = {
NULL
};
static const char *req_header_header_names[] = {
static const char *const req_header_header_names[] = {
"User-Agent",
"Proxy-Connection",
"Referer",
@ -1858,7 +1858,7 @@ static const char *req_header_header_names[] = {
static const char *req_header_var_fn(ap_expr_eval_ctx_t *ctx, const void *data)
{
const char **varname = (const char **)data;
const char **const varname = (const char **)data;
int index = (varname - req_header_var_names);
const char *name;
@ -1876,7 +1876,7 @@ static const char *req_header_var_fn(ap_expr_eval_ctx_t *ctx, const void *data)
return apr_table_get(ctx->r->headers_in, name);
}
static const char *misc_var_names[] = {
static const char *const misc_var_names[] = {
"TIME_YEAR", /* 0 */
"TIME_MON", /* 1 */
"TIME_DAY", /* 2 */
@ -2033,7 +2033,7 @@ struct expr_provider_single {
struct expr_provider_multi {
const void *func;
const char **names;
const char *const *names;
};
static const struct expr_provider_multi var_providers[] = {
@ -2104,7 +2104,7 @@ static int core_expr_lookup(ap_expr_lookup_parms *parms)
case AP_EXPR_FUNC_VAR: {
const struct expr_provider_multi *prov = var_providers;
while (prov->func) {
const char **name = prov->names;
const char *const *name = prov->names;
while (*name) {
if (ap_cstr_casecmp(*name, parms->name) == 0) {
*parms->func = prov->func;