Author: wyoung
Date: Thu Nov 15 14:37:58 2007
New Revision: 1849

URL: http://svn.gna.org/viewcvs/mysqlpp?rev=1849&view=rev
Log:
Replaced a few more misuses of SQLTypeAdapter with std::string

Modified:
    trunk/lib/query.cpp

Modified: trunk/lib/query.cpp
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/query.cpp?rev=1849&r1=1848&r2=1849&view=diff
==============================================================================
--- trunk/lib/query.cpp (original)
+++ trunk/lib/query.cpp Thu Nov 15 14:37:58 2007
@@ -281,13 +281,14 @@
        }
 
        if (option == 'r' || (option == 'q' && S.is_string())) {
-               char *s = new char[S.size() * 2 + 1];
-               mysql_real_escape_string(&conn_->mysql_, s, S.data(),
-                               static_cast<unsigned long>(S.size()));
-               SQLTypeAdapter *ss = new SQLTypeAdapter("'");
-               *ss += s;
-               *ss += "'";
-               delete[] s;
+               char *escaped = new char[S.size() * 2 + 1];
+               size_t len = mysql_real_escape_string(&conn_->mysql_, escaped,
+                               S.data(), static_cast<unsigned long>(S.size()));
+               std::string temp("'", 1);
+               temp.append(escaped, len);
+               temp.append("'", 1);
+               delete[] escaped;
+               SQLTypeAdapter* ss = new SQLTypeAdapter(temp);
 
                if (replace) {
                        S = *ss;
@@ -300,7 +301,10 @@
                }
        }
        else if (option == 'R' || (option == 'Q' && S.is_string())) {
-               SQLTypeAdapter *ss = new SQLTypeAdapter("'" + S + "'");
+               std::string temp("'", 1);
+               temp.append(S.data(), S.length());
+               temp.append("'", 1);
+               SQLTypeAdapter *ss = new SQLTypeAdapter(temp);
 
                if (replace) {
                        S = *ss;


_______________________________________________
Mysqlpp-commits mailing list
[email protected]
https://mail.gna.org/listinfo/mysqlpp-commits

Reply via email to