From: Takashi Sato Date: Tue, 16 Dec 2008 00:08:01 +0000 (+0000) Subject: * Change some "apr_palloc / memcpy" to apr_pstrmemdup X-Git-Tag: 2.3.1~116 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4975fd3583b510f5962f215156c3c73756f570c8;p=thirdparty%2Fapache%2Fhttpd.git * Change some "apr_palloc / memcpy" to apr_pstrmemdup PR: 39519 Submitted by: Christophe JAILLET * Remove unnecessary casts git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@726884 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/server/util.c b/server/util.c index 3651e05931a..795cbcb2d28 100644 --- a/server/util.c +++ b/server/util.c @@ -578,9 +578,8 @@ AP_DECLARE(char *) ap_make_dirstr_parent(apr_pool_t *p, const char *s) return apr_pstrdup(p, ""); } l = (last_slash - s) + 1; - d = apr_palloc(p, l + 1); - memcpy(d, s, l); - d[l] = 0; + d = apr_pstrmemdup(p, s, l); + return (d); } @@ -611,9 +610,7 @@ AP_DECLARE(char *) ap_getword(apr_pool_t *atrans, const char **line, char stop) } len = pos - *line; - res = (char *)apr_palloc(atrans, len + 1); - memcpy(res, *line, len); - res[len] = 0; + res = apr_pstrmemdup(atrans, *line, len); if (stop) { while (*pos == stop) { @@ -641,9 +638,7 @@ AP_DECLARE(char *) ap_getword_white(apr_pool_t *atrans, const char **line) } len = pos - *line; - res = (char *)apr_palloc(atrans, len + 1); - memcpy(res, *line, len); - res[len] = 0; + res = apr_pstrmemdup(atrans, *line, len); while (apr_isspace(*pos)) { ++pos; diff --git a/support/ab.c b/support/ab.c index 95b48a4fc06..4a35903228f 100644 --- a/support/ab.c +++ b/support/ab.c @@ -1892,9 +1892,7 @@ static int parse_url(char *url) if ((cp = strchr(url, '/')) == NULL) return 1; - h = apr_palloc(cntxt, cp - url + 1); - memcpy(h, url, cp - url); - h[cp - url] = '\0'; + h = apr_pstrmemdup(cntxt, url, cp - url); rv = apr_parse_addr_port(&hostname, &scope_id, &port, h, cntxt); if (rv != APR_SUCCESS || !hostname || scope_id) { return 1;