From: Christophe Jaillet Date: Fri, 6 Nov 2015 21:59:53 +0000 (+0000) Subject: Save a few bytes in conf pool when processing 'Define'. X-Git-Tag: 2.5.0-alpha~2658 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fba65e6213d2e6dec7d9db9504e1c666139e5eae;p=apache Save a few bytes in conf pool when processing 'Define'. + some minor style issues + split long lines git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1713043 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/server/core.c b/server/core.c index b3f622db60..a2d54d0852 100644 --- a/server/core.c +++ b/server/core.c @@ -1361,21 +1361,25 @@ static const char *set_define(cmd_parms *cmd, void *dummy, const char *name, const char *value) { if (cmd->parent && strcasecmp(cmd->parent->directive, "pool, cmd->cmd->name, " is not valid in ", cmd->parent->directive, " context", NULL); + return apr_pstrcat(cmd->pool, cmd->cmd->name, " is not valid in ", + cmd->parent->directive, " context", NULL); } - if (ap_strchr_c(name, ':') != NULL) + if (ap_strchr_c(name, ':') != NULL) { return "Variable name must not contain ':'"; + } - if (!saved_server_config_defines) + if (!saved_server_config_defines) { init_config_defines(cmd->pool); + } if (!ap_exists_config_define(name)) { - char **newv = (char **)apr_array_push(ap_server_config_defines); - *newv = apr_pstrdup(cmd->pool, name); + const char **newv = (const char **)apr_array_push(ap_server_config_defines); + *newv = name; } if (value) { - if (!server_config_defined_vars) + if (!server_config_defined_vars) { server_config_defined_vars = apr_table_make(cmd->pool, 5); + } apr_table_setn(server_config_defined_vars, name, value); } @@ -1388,14 +1392,17 @@ static const char *unset_define(cmd_parms *cmd, void *dummy, int i; char **defines; if (cmd->parent && strcasecmp(cmd->parent->directive, "pool, cmd->cmd->name, " is not valid in ", cmd->parent->directive, " context", NULL); + return apr_pstrcat(cmd->pool, cmd->cmd->name, " is not valid in ", + cmd->parent->directive, " context", NULL); } - if (ap_strchr_c(name, ':') != NULL) + if (ap_strchr_c(name, ':') != NULL) { return "Variable name must not contain ':'"; + } - if (!saved_server_config_defines) + if (!saved_server_config_defines) { init_config_defines(cmd->pool); + } defines = (char **)ap_server_config_defines->elts; for (i = 0; i < ap_server_config_defines->nelts; i++) {