Hans Leidekker : wmiutils: Implement IWbemPathKeyList::RemoveAllKeys.

Alexandre Julliard julliard at winehq.org
Thu Feb 21 14:29:36 CST 2013


Module: wine
Branch: master
Commit: 612caa5d393c45dd4e3e6491f0835bdeb22df603
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=612caa5d393c45dd4e3e6491f0835bdeb22df603

Author: Hans Leidekker <hans at codeweavers.com>
Date:   Thu Feb 21 10:46:54 2013 +0100

wmiutils: Implement IWbemPathKeyList::RemoveAllKeys.

---

 dlls/wmiutils/path.c |   54 +++++++++++++++++++++++++++++++++----------------
 1 files changed, 36 insertions(+), 18 deletions(-)

diff --git a/dlls/wmiutils/path.c b/dlls/wmiutils/path.c
index 98f22db..dcade46 100644
--- a/dlls/wmiutils/path.c
+++ b/dlls/wmiutils/path.c
@@ -39,6 +39,14 @@ struct keylist
     LONG             refs;
 };
 
+struct key
+{
+    WCHAR *name;
+    int    len_name;
+    WCHAR *value;
+    int    len_value;
+};
+
 struct path
 {
     IWbemPath        IWbemPath_iface;
@@ -191,12 +199,37 @@ static HRESULT WINAPI keylist_RemoveKey(
     return E_NOTIMPL;
 }
 
+static void free_keys( struct key *keys, unsigned int count )
+{
+    unsigned int i;
+
+    for (i = 0; i < count; i++)
+    {
+        heap_free( keys[i].name );
+        heap_free( keys[i].value );
+    }
+    heap_free( keys );
+}
+
 static HRESULT WINAPI keylist_RemoveAllKeys(
     IWbemPathKeyList *iface,
     ULONG uFlags )
 {
-    FIXME("%p, 0x%x\n", iface, uFlags);
-    return E_NOTIMPL;
+    struct keylist *keylist = impl_from_IWbemPathKeyList( iface );
+    struct path *parent = impl_from_IWbemPath( keylist->parent );
+
+    TRACE("%p, 0x%x\n", iface, uFlags);
+
+    if (uFlags) return WBEM_E_INVALID_PARAMETER;
+
+    EnterCriticalSection( &parent->cs );
+
+    free_keys( parent->keys, parent->num_keys );
+    parent->num_keys = 0;
+    parent->keys = NULL;
+
+    LeaveCriticalSection( &parent->cs );
+    return S_OK;
 }
 
 static HRESULT WINAPI keylist_MakeSingleton(
@@ -262,14 +295,6 @@ static HRESULT WbemPathKeyList_create( IUnknown *pUnkOuter, IWbemPath *parent, L
     return S_OK;
 }
 
-struct key
-{
-    WCHAR *name;
-    int    len_name;
-    WCHAR *value;
-    int    len_value;
-};
-
 static void init_path( struct path *path )
 {
     path->text           = NULL;
@@ -288,19 +313,12 @@ static void init_path( struct path *path )
 
 static void clear_path( struct path *path )
 {
-    unsigned int i;
-
     heap_free( path->text );
     heap_free( path->server );
     heap_free( path->namespaces );
     heap_free( path->len_namespaces );
     heap_free( path->class );
-    for (i = 0; i < path->num_keys; i++)
-    {
-        heap_free( path->keys[i].name );
-        heap_free( path->keys[i].value );
-    }
-    heap_free( path->keys );
+    free_keys( path->keys, path->num_keys );
     init_path( path );
 }
 




More information about the wine-cvs mailing list