httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s.@apache.org
Subject svn commit: r1325646 - /httpd/mod_mbox/branches/convert-charsets/module-2.0/mod_mbox.c
Date Fri, 13 Apr 2012 08:09:34 GMT
Author: sf
Date: Fri Apr 13 08:09:34 2012
New Revision: 1325646

URL: http://svn.apache.org/viewvc?rev=1325646&view=rev
Log:
avoid useless memory allocations and copying in mbox_cntrl_escape()

Modified:
    httpd/mod_mbox/branches/convert-charsets/module-2.0/mod_mbox.c

Modified: httpd/mod_mbox/branches/convert-charsets/module-2.0/mod_mbox.c
URL: http://svn.apache.org/viewvc/httpd/mod_mbox/branches/convert-charsets/module-2.0/mod_mbox.c?rev=1325646&r1=1325645&r2=1325646&view=diff
==============================================================================
--- httpd/mod_mbox/branches/convert-charsets/module-2.0/mod_mbox.c (original)
+++ httpd/mod_mbox/branches/convert-charsets/module-2.0/mod_mbox.c Fri Apr 13 08:09:34 2012
@@ -192,14 +192,14 @@ char *mbox_cntrl_escape(apr_pool_t *p, c
         return s;
 
     x = apr_palloc(p, i + j + 1);
-    for (i = 0, j = 0; s[i] != '\0'; i++, j++)
+    for (i = 0, j = 0; s[i] != '\0'; i++, j++) {
         if (apr_iscntrl(s[i])) {
-            char *esc = apr_psprintf(p, "&#%3.3d;", (unsigned char)s[i]);
-            memcpy(&x[j], esc, 6);
+            snprintf(&x[j], 7, "&#%3.3d;", (unsigned char)s[i]);
             j += 5;
         }
         else
             x[j] = s[i];
+    }
 
     x[j] = '\0';
     return x;



Mime
View raw message