One more static const string

Francois Gouget fgouget at free.fr
Tue May 4 16:48:50 CDT 2004


On Tue, 4 May 2004, Alexandre Julliard wrote:
[...]
> The string can't be const, it gets modified.

Damn.

I thought RtlInitString was taking a copy of the string. RtlInitString
looks like a nice API to avoid (const char*) to (char*) warnings.

However then I'd say two things are wrong:

 * deststring should not be static. Otherwise test_RtlCopyString()
can't be called twice (which we don't do but still it would be cleaner).

 * also I can't help but wonder what's the point of the
'strncmp(str.Buffer, deststring...)' comparison since
str.Buffer == deststring (as per the RtlInitAnsiString() code). I think
the intent was to compare it with teststring.


Changelog:

 * dlls/ntdll/tests/rtlstr.c

   We should not make deststring static since we count on it being
fresh and clean when entering test_RtlCopyString().
   Fix the RtlCopyString check.


Index: dlls/ntdll/tests/rtlstr.c
===================================================================
RCS file: /var/cvs/wine/dlls/ntdll/tests/rtlstr.c,v
retrieving revision 1.16
diff -u -r1.16 rtlstr.c
--- a/dlls/ntdll/tests/rtlstr.c	20 Apr 2004 01:12:17 -0000	1.16
+++ b/dlls/ntdll/tests/rtlstr.c	4 May 2004 21:36:01 -0000
@@ -479,14 +479,14 @@
 static void test_RtlCopyString(void)
 {
     static const char teststring[] = "Some Wild String";
-    static char deststring[] = "                    ";
+    char deststring[] = "                    ";
     STRING str;
     STRING deststr;

     pRtlInitString(&str, teststring);
     pRtlInitString(&deststr, deststring);
     pRtlCopyString(&deststr, &str);
-    ok(strncmp(str.Buffer, deststring, str.Length) == 0, "String not copied\n");
+    ok(strncmp(str.Buffer, teststring, str.Length) == 0, "String not copied\n");
 }



-- 
Francois Gouget         fgouget at free.fr        http://fgouget.free.fr/
         Demander si un ordinateur peut penser revient \xE0 demander
                         si un sous-marin peut nager.



More information about the wine-patches mailing list