apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jor...@apache.org
Subject svn commit: r1683521 - /apr/apr/trunk/network_io/unix/sockaddr.c
Date Thu, 04 Jun 2015 11:24:21 GMT
Author: jorton
Date: Thu Jun  4 11:24:20 2015
New Revision: 1683521

URL: http://svn.apache.org/r1683521
Log:
* network_io/unix/sockaddr.c (apr_parse_addr_port): Simplify to use
  apr_pstrmemdup, no functional change.

Modified:
    apr/apr/trunk/network_io/unix/sockaddr.c

Modified: apr/apr/trunk/network_io/unix/sockaddr.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/network_io/unix/sockaddr.c?rev=1683521&r1=1683520&r2=1683521&view=diff
==============================================================================
--- apr/apr/trunk/network_io/unix/sockaddr.c (original)
+++ apr/apr/trunk/network_io/unix/sockaddr.c Thu Jun  4 11:24:20 2015
@@ -277,19 +277,13 @@ APR_DECLARE(apr_status_t) apr_parse_addr
                 return APR_EINVAL;
             }
             addrlen = scope_delim - str - 1;
-            *scope_id = apr_palloc(p, end_bracket - scope_delim);
-            memcpy(*scope_id, scope_delim + 1, end_bracket - scope_delim - 1);
-            (*scope_id)[end_bracket - scope_delim - 1] = '\0';
+            *scope_id = apr_pstrmemdup(p, scope_delim, end_bracket - scope_delim - 1);
         }
         else {
             addrlen = addrlen - 2; /* minus 2 for '[' and ']' */
         }
 
-        *addr = apr_palloc(p, addrlen + 1);
-        memcpy(*addr,
-               str + 1,
-               addrlen);
-        (*addr)[addrlen] = '\0';
+        *addr = apr_pstrmemdup(p, str + 1, addrlen);
         if (apr_inet_pton(AF_INET6, *addr, &ipaddr) != 1) {
             *addr = NULL;
             *scope_id = NULL;
@@ -303,9 +297,7 @@ APR_DECLARE(apr_status_t) apr_parse_addr
         /* XXX If '%' is not a valid char in a DNS name, we *could* check 
          *     for bogus scope ids first.
          */
-        *addr = apr_palloc(p, addrlen + 1);
-        memcpy(*addr, str, addrlen);
-        (*addr)[addrlen] = '\0';
+        *addr = apr_pstrmemdup(p, str, addrlen);
     }
     return APR_SUCCESS;
 }



Mime
View raw message