msvcrt: The tests link with msvcrt(d).dll now, so use GetModuleHandle() rather than LoadLibrary().

Francois Gouget fgouget at free.fr
Wed Dec 13 10:52:55 CST 2006


---

data.c is already using GetModuleHandleA() so we should standardize one 
way or the other. GetModuleHandleA() seems lighter weight and will also 
test msvcrtd.dll depending on how we link. So that's the way I went.

 dlls/msvcrt/tests/cpp.c    |    4 +++-
 dlls/msvcrt/tests/string.c |    9 +++++++--
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/dlls/msvcrt/tests/cpp.c b/dlls/msvcrt/tests/cpp.c
index a411212..b9acbb1 100644
--- a/dlls/msvcrt/tests/cpp.c
+++ b/dlls/msvcrt/tests/cpp.c
@@ -184,7 +184,9 @@ static void* do_call_func2(void *func, void *_this, const void* arg)
 
 static void InitFunctionPtrs(void)
 {
-  hMsvcrt = LoadLibraryA("msvcrt.dll");
+  hMsvcrt = GetModuleHandleA("msvcrt.dll");
+  if (!hMsvcrt)
+    hMsvcrt = GetModuleHandleA("msvcrtd.dll");
   ok(hMsvcrt != 0, "LoadLibraryA failed\n");
   if (hMsvcrt)
   {
diff --git a/dlls/msvcrt/tests/string.c b/dlls/msvcrt/tests/string.c
index a86f91e..cd4ca02 100644
--- a/dlls/msvcrt/tests/string.c
+++ b/dlls/msvcrt/tests/string.c
@@ -111,8 +111,12 @@ START_TEST(string)
 {
     void *mem;
     static const char xilstring[]="c:/xilinx";
-    int nLen=strlen(xilstring);
-    HMODULE hMsvcrt = LoadLibraryA("msvcrt.dll");
+    int nLen;
+    HMODULE hMsvcrt;
+
+    hMsvcrt = GetModuleHandleA("msvcrt.dll");
+    if (!hMsvcrt)
+        hMsvcrt = GetModuleHandleA("msvcrtd.dll");
     ok(hMsvcrt != 0, "LoadLibraryA failed\n");
     SET(pmemcpy,"memcpy");
     SET(pmemcmp,"memcmp");
@@ -122,6 +126,7 @@ START_TEST(string)
     mem = malloc(100);
     ok(mem != NULL, "memory not allocated for size 0\n");
     strcpy((char*)mem,xilstring);
+    nLen=strlen(xilstring);
     pmemcpy((char*)mem+5, mem,nLen+1);
     ok(pmemcmp((char*)mem+5,xilstring, nLen) == 0, 
        "Got result %s\n",(char*)mem+5);
-- 
1.4.4.1




More information about the wine-patches mailing list