[Rcpp-commits] r2782 - in pkg/Rcpp: . inst/include/Rcpp

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Dec 12 18:05:50 CET 2010


Author: romain
Date: 2010-12-12 18:05:50 +0100 (Sun, 12 Dec 2010)
New Revision: 2782

Modified:
   pkg/Rcpp/ChangeLog
   pkg/Rcpp/inst/include/Rcpp/sprintf.h
Log:
sprintf returns a std::string to avoid mem leaks

Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog	2010-12-12 12:46:20 UTC (rev 2781)
+++ pkg/Rcpp/ChangeLog	2010-12-12 17:05:50 UTC (rev 2782)
@@ -2,6 +2,8 @@
 
     * R/SHLIB.R: new unexported R function SHLIB, small wrapper around 
     R CMD SHLIB
+    
+    * inst/include/Rcpp/sprintf.h: returning a std::string to avoid leaks
 
 2010-12-10  Dirk Eddelbuettel  <edd at debian.org>
 

Modified: pkg/Rcpp/inst/include/Rcpp/sprintf.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/sprintf.h	2010-12-12 12:46:20 UTC (rev 2781)
+++ pkg/Rcpp/inst/include/Rcpp/sprintf.h	2010-12-12 17:05:50 UTC (rev 2782)
@@ -25,13 +25,13 @@
 namespace Rcpp{
 
 template <int MAX_SIZE>
-const char* sprintf( const char *format, ...) {
+std::string sprintf( const char *format, ...) {
     static char buffer[MAX_SIZE]; 
     va_list(ap);
     va_start(ap, format);
     vsnprintf( buffer, MAX_SIZE, format, ap);
     va_end(ap);
-    return strdup( buffer ) ;
+    return buffer ;
 }
 
 }



More information about the Rcpp-commits mailing list