From 6f95c6990af0e009ad43d2cb06e4c3e0629190c1 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Mon, 16 Apr 2012 09:32:03 +0400 Subject: [PATCH] msxml3: Added IMXAttributes::clear(). --- dlls/msxml3/mxwriter.c | 19 +++++++++++++++++-- dlls/msxml3/tests/saxreader.c | 8 ++++---- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/dlls/msxml3/mxwriter.c b/dlls/msxml3/mxwriter.c index 41979e689ff..a5b9684715f 100644 --- a/dlls/msxml3/mxwriter.c +++ b/dlls/msxml3/mxwriter.c @@ -1665,8 +1665,23 @@ static HRESULT WINAPI MXAttributes_addAttributeFromIndex(IMXAttributes *iface, static HRESULT WINAPI MXAttributes_clear(IMXAttributes *iface) { mxattributes *This = impl_from_IMXAttributes( iface ); - FIXME("(%p): stub\n", This); - return E_NOTIMPL; + int i; + + TRACE("(%p)\n", This); + + for (i = 0; i < This->length; i++) + { + SysFreeString(This->attr[i].qname); + SysFreeString(This->attr[i].local); + SysFreeString(This->attr[i].uri); + SysFreeString(This->attr[i].type); + SysFreeString(This->attr[i].value); + memset(&This->attr[i], 0, sizeof(mxattribute)); + } + + This->length = 0; + + return S_OK; } static HRESULT WINAPI MXAttributes_removeAttribute(IMXAttributes *iface, int index) diff --git a/dlls/msxml3/tests/saxreader.c b/dlls/msxml3/tests/saxreader.c index 4e2bd115790..afe887c3a5d 100644 --- a/dlls/msxml3/tests/saxreader.c +++ b/dlls/msxml3/tests/saxreader.c @@ -4068,6 +4068,9 @@ static void test_mxattr_clear(void) hr = ISAXAttributes_getQName(saxattr, 0, &ptr, &len); EXPECT_HR(hr, E_INVALIDARG); + hr = IMXAttributes_clear(mxattr); + EXPECT_HR(hr, S_OK); + hr = IMXAttributes_addAttribute(mxattr, _bstr_("uri"), _bstr_("local"), _bstr_("qname"), _bstr_("type"), _bstr_("value")); EXPECT_HR(hr, S_OK); @@ -4094,23 +4097,20 @@ static void test_mxattr_clear(void) ok(!lstrcmpW(ptr, _bstr_("qname")), "got %s\n", wine_dbgstr_w(ptr)); hr = IMXAttributes_clear(mxattr); -todo_wine EXPECT_HR(hr, S_OK); len = -1; hr = ISAXAttributes_getLength(saxattr, &len); EXPECT_HR(hr, S_OK); -todo_wine ok(len == 0, "got %d\n", len); len = -1; ptr = (void*)0xdeadbeef; hr = ISAXAttributes_getQName(saxattr, 0, &ptr, &len); -todo_wine { EXPECT_HR(hr, E_INVALIDARG); ok(len == -1, "got %d\n", len); ok(ptr == (void*)0xdeadbeef, "got %p\n", ptr); -} + IMXAttributes_Release(mxattr); ISAXAttributes_Release(saxattr); free_bstrs();