CString patch

porten at froglogic.com porten at froglogic.com
Mon Oct 27 01:29:55 CET 2003


Hi,

I just merged JavaScriptCore's CString to have a length member. Attached
you'll find a patch that fixes an initialization bug in the copy ctor.
Please review the review of your reviewed change ;)
It also contains two changes of the can't-make-it-slower kind.

Harri.

-------------- next part --------------
? BackwardsForDeclarations.txt
? argument.diff
? cstring.diff
? diff.txt
? grammar.diff
? isnan.diff
? kjs.tar.gz
? proplistall.diff
Index: ustring.cpp
===================================================================
RCS file: /home/kde/kdelibs/kjs/ustring.cpp,v
retrieving revision 1.64
diff -u -3 -p -r1.64 ustring.cpp
--- ustring.cpp	26 Oct 2003 23:49:34 -0000	1.64
+++ ustring.cpp	27 Oct 2003 00:05:14 -0000
@@ -52,7 +52,7 @@ CString::CString(const char *c)
 {
   length = strlen(c);
   data = new char[length+1];
-  strcpy(data, c);
+  memcpy(data, c, length + 1);
 }
 
 CString::CString(const char *c, int len)
@@ -67,7 +67,7 @@ CString::CString(const CString &b)
 {
   length = b.length;
   data = new char[length+1];
-  memcpy(data, b.data, length);
+  memcpy(data, b.data, length + 1);
 }
 
 CString::~CString()
@@ -97,7 +97,7 @@ CString &CString::operator=(const char *
     delete [] data;
   length = strlen(c);
   data = new char[length+1];
-  strcpy(data, c);
+  memcpy(data, c, length + 1);
 
   return *this;
 }


More information about the Khtml-devel mailing list