You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Christophe JAILLET <ch...@wanadoo.fr> on 2015/08/19 19:42:49 UTC

Re: svn commit: r1696607 - in /httpd/httpd/trunk/modules/http2: h2_alt_svc.c h2_config.c h2_request.c h2_response.c

Hi,

in the 2 functions below, you could also use apr_pstrcat instead of a 
hard coded (20) for extra space needed by '[', ']', ... + 
apr_pcalloc/strlen/strcpy/strcat
This is cleaner, IMHO and less verbose (and faster but we don't really 
care here).

CJ

Le 19/08/2015 16:55, icing@apache.org a écrit :
> Author: icing
> Date: Wed Aug 19 14:55:26 2015
> New Revision: 1696607
>
>
>
> Modified: httpd/httpd/trunk/modules/http2/h2_config.c
> URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http2/h2_config.c?rev=1696607&r1=1696606&r2=1696607&view=diff
> ==============================================================================
> --- httpd/httpd/trunk/modules/http2/h2_config.c (original)
> +++ httpd/httpd/trunk/modules/http2/h2_config.c Wed Aug 19 14:55:26 2015
> @@ -58,7 +58,7 @@ static void *h2_config_create(apr_pool_t
>       h2_config *conf = (h2_config *)apr_pcalloc(pool, sizeof(h2_config));
>       
>       const char *s = x? x : "unknown";
> -    char *name = (char *)apr_pcalloc(pool, strlen(prefix) + strlen(s) + 20);
> +    char *name = apr_pcalloc(pool, strlen(prefix) + strlen(s) + 20);
>       strcpy(name, prefix);
>       strcat(name, "[");
>       strcat(name, s);
> @@ -97,8 +97,7 @@ void *h2_config_merge(apr_pool_t *pool,
>       h2_config *add = (h2_config *)addv;
>       h2_config *n = (h2_config *)apr_pcalloc(pool, sizeof(h2_config));
>   
> -    char *name = (char *)apr_pcalloc(pool,
> -        20 + strlen(add->name) + strlen(base->name));
> +    char *name = apr_pcalloc(pool, 20 + strlen(add->name) + strlen(base->name));
>       strcpy(name, "merged[");
>       strcat(name, add->name);
>       strcat(name, ", ");
>
>