[PATCH] userenv: Implement DestroyEnvironmentBlock().

Lei Zhang thestig at google.com
Mon Feb 1 19:26:03 CST 2010


Hi,

Over the weekend, someone wrote a Chromium base unit test that calls
DestroyEnvironmentBlock(). So I guess it's time to implement it. The
modified Wine test case passed on my WinXP machine.

- Lei
-------------- next part --------------
From 374cff93f733a3772389a1e3eeeac95f52f1ad44 Mon Sep 17 00:00:00 2001
From: Lei Zhang <thestig at google.com>
Date: Mon, 1 Feb 2010 17:15:22 -0800
Subject: [PATCH] userenv: Implement DestroyEnvironmentBlock().

---
 dlls/userenv/tests/userenv.c |    6 ++++++
 dlls/userenv/userenv.spec    |    2 +-
 dlls/userenv/userenv_main.c  |   15 +++++++++++++++
 include/userenv.h            |    1 +
 4 files changed, 23 insertions(+), 1 deletions(-)

diff --git a/dlls/userenv/tests/userenv.c b/dlls/userenv/tests/userenv.c
index 39c1bbf..c61958f 100644
--- a/dlls/userenv/tests/userenv.c
+++ b/dlls/userenv/tests/userenv.c
@@ -197,6 +197,12 @@ static void test_create_env(void)
     r = get_env(env[3], "WINE_XYZZY", &st);
     expect(TRUE, r);
     if (r) HeapFree(GetProcessHeap(), 0, st);
+
+    for (i = 0; i < sizeof(env) / sizeof(env[0]); i++)
+    {
+        r = DestroyEnvironmentBlock(env[i]);
+        expect(TRUE, r);
+    }
 }
 
 START_TEST(userenv)
diff --git a/dlls/userenv/userenv.spec b/dlls/userenv/userenv.spec
index 26475e5..8b0b749 100644
--- a/dlls/userenv/userenv.spec
+++ b/dlls/userenv/userenv.spec
@@ -1,5 +1,5 @@
 @ stdcall CreateEnvironmentBlock(ptr ptr long)
-@ stub DestroyEnvironmentBlock
+@ stdcall DestroyEnvironmentBlock(ptr)
 @ stdcall ExpandEnvironmentStringsForUserA(ptr str ptr long)
 @ stdcall ExpandEnvironmentStringsForUserW(ptr wstr ptr long)
 @ stdcall GetAllUsersProfileDirectoryA(ptr ptr)
diff --git a/dlls/userenv/userenv_main.c b/dlls/userenv/userenv_main.c
index 8782c94..4f2b490 100644
--- a/dlls/userenv/userenv_main.c
+++ b/dlls/userenv/userenv_main.c
@@ -65,6 +65,21 @@ BOOL WINAPI CreateEnvironmentBlock( LPVOID* lpEnvironment,
     return FALSE;
 }
 
+BOOL WINAPI DestroyEnvironmentBlock( LPVOID lpEnvironment )
+{
+    NTSTATUS r;
+
+    TRACE("%p\n", lpEnvironment);
+
+    if (!lpEnvironment)
+        return FALSE;
+
+    r = RtlDestroyEnvironment((WCHAR *)lpEnvironment);
+    if (r == STATUS_SUCCESS)
+        return TRUE;
+    return FALSE;
+}
+
 BOOL WINAPI ExpandEnvironmentStringsForUserA( HANDLE hToken, LPCSTR lpSrc,
                      LPSTR lpDest, DWORD dwSize )
 {
diff --git a/include/userenv.h b/include/userenv.h
index 507715f..de8bbe0 100644
--- a/include/userenv.h
+++ b/include/userenv.h
@@ -31,6 +31,7 @@ extern "C" {
 #endif
 
 BOOL WINAPI CreateEnvironmentBlock(LPVOID*,HANDLE,BOOL);
+BOOL WINAPI DestroyEnvironmentBlock(LPVOID);
 BOOL WINAPI ExpandEnvironmentStringsForUserA(HANDLE,LPCSTR,LPSTR,DWORD);
 BOOL WINAPI ExpandEnvironmentStringsForUserW(HANDLE,LPCWSTR,LPWSTR,DWORD);
 #define     ExpandEnvironmentStringsForUser WINELIB_NAME_AW(ExpandEnvironmentStringsForUser)
-- 
1.6.6


More information about the wine-patches mailing list