You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ja...@apache.org on 2018/06/12 17:13:28 UTC

svn commit: r1833415 - /httpd/httpd/trunk/modules/http2/h2_proxy_util.c

Author: jailletc36
Date: Tue Jun 12 17:13:27 2018
New Revision: 1833415

URL: http://svn.apache.org/viewvc?rev=1833415&view=rev
Log:
apr_pcalloc can be turned into apr_palloc (the allocated memory is fully initialized by the subsequent memcpy/strcpy) and '(int)strlen(p)' can be replaced by 'plen - 1' to save some cycles.

Modified:
    httpd/httpd/trunk/modules/http2/h2_proxy_util.c

Modified: httpd/httpd/trunk/modules/http2/h2_proxy_util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http2/h2_proxy_util.c?rev=1833415&r1=1833414&r2=1833415&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/http2/h2_proxy_util.c (original)
+++ httpd/httpd/trunk/modules/http2/h2_proxy_util.c Tue Jun 12 17:13:27 2018
@@ -915,12 +915,12 @@ static size_t subst_str(link_ctx *ctx, i
     nlen = (int)strlen(ns);
     delta = nlen - olen;
     plen = ctx->slen + delta + 1;
-    p = apr_pcalloc(ctx->pool, plen);
+    p = apr_palloc(ctx->pool, plen);
     memcpy(p, ctx->s, start);
     memcpy(p + start, ns, nlen);
     strcpy(p + start + nlen, ctx->s + end);
     ctx->s = p;
-    ctx->slen = (int)strlen(p);
+    ctx->slen = plen - 1;   /* (int)strlen(p) */
     if (ctx->i >= end) {
         ctx->i += delta;
     }