From 612caa5d393c45dd4e3e6491f0835bdeb22df603 Mon Sep 17 00:00:00 2001 From: Hans Leidekker Date: Thu, 21 Feb 2013 10:46:54 +0100 Subject: [PATCH] wmiutils: Implement IWbemPathKeyList::RemoveAllKeys. --- dlls/wmiutils/path.c | 54 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/dlls/wmiutils/path.c b/dlls/wmiutils/path.c index 98f22dbaade..dcade4638c9 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 ); } -- 2.11.4.GIT