subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From julianf...@apache.org
Subject svn commit: r1140087 - /subversion/trunk/subversion/libsvn_subr/svn_base64.c
Date Mon, 27 Jun 2011 10:23:54 GMT
Author: julianfoad
Date: Mon Jun 27 10:23:54 2011
New Revision: 1140087

URL: http://svn.apache.org/viewvc?rev=1140087&view=rev
Log:
* subversion/libsvn_subr/svn_base64.c
  (svn_base64_encode_string2, svn_base64_decode_string): Simplify the
    conversion from stringbuf to string, eliminating a pool allocation.

Modified:
    subversion/trunk/subversion/libsvn_subr/svn_base64.c

Modified: subversion/trunk/subversion/libsvn_subr/svn_base64.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/svn_base64.c?rev=1140087&r1=1140086&r2=1140087&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/svn_base64.c (original)
+++ subversion/trunk/subversion/libsvn_subr/svn_base64.c Mon Jun 27 10:23:54 2011
@@ -33,6 +33,7 @@
 #include "svn_io.h"
 #include "svn_error.h"
 #include "svn_base64.h"
+#include "private/svn_string_private.h"
 
 /* When asked to format the the base64-encoded output as multiple lines, 
    we put this many chars in each line (plus one new line char) unless
@@ -267,7 +268,6 @@ svn_base64_encode_string2(const svn_stri
                           apr_pool_t *pool)
 {
   svn_stringbuf_t *encoded = svn_stringbuf_create("", pool);
-  svn_string_t *retval = apr_pcalloc(pool, sizeof(*retval));
   unsigned char ingroup[3];
   size_t ingrouplen = 0;
   size_t linelen = 0;
@@ -276,9 +276,7 @@ svn_base64_encode_string2(const svn_stri
                break_lines);
   encode_partial_group(encoded, ingroup, ingrouplen, linelen,
                        break_lines);
-  retval->data = encoded->data;
-  retval->len = encoded->len;
-  return retval;
+  return svn_stringbuf__morph_into_string(encoded);
 }
 
 const svn_string_t *
@@ -510,15 +508,12 @@ const svn_string_t *
 svn_base64_decode_string(const svn_string_t *str, apr_pool_t *pool)
 {
   svn_stringbuf_t *decoded = svn_stringbuf_create("", pool);
-  svn_string_t *retval = apr_pcalloc(pool, sizeof(*retval));
   unsigned char ingroup[4];
   int ingrouplen = 0;
   svn_boolean_t done = FALSE;
 
   decode_bytes(decoded, str->data, str->len, ingroup, &ingrouplen, &done);
-  retval->data = decoded->data;
-  retval->len = decoded->len;
-  return retval;
+  return svn_stringbuf__morph_into_string(decoded);
 }
 
 



Mime
View raw message