]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
* Change some "apr_palloc / memcpy" to apr_pstrmemdup
authorTakashi Sato <takashi@apache.org>
Tue, 16 Dec 2008 00:08:01 +0000 (00:08 +0000)
committerTakashi Sato <takashi@apache.org>
Tue, 16 Dec 2008 00:08:01 +0000 (00:08 +0000)
PR: 39519
Submitted by: Christophe JAILLET <christophe.jaillet wanadoo.fr>

* Remove unnecessary casts

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@726884 13f79535-47bb-0310-9956-ffa450edef68

server/util.c
support/ab.c

index 3651e05931af172a2b9b005f090d3e8151f3dead..795cbcb2d28d332b3ee00ee78e11908cad40c0b4 100644 (file)
@@ -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;
index 95b48a4fc0636c98081c319263223e050d11c8d0..4a35903228fbcb083b4f23caa86da4690c589e8e 100644 (file)
@@ -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;