oledb32: Implement IErrorRecord AddErrorRecord
Alistair Leslie-Hughes
leslie_alistair at hotmail.com
Tue Aug 20 04:37:58 CDT 2013
Hi,
Update to make a deep copy of the ERRORINFO.
Changelog:
oledb32: Implement IErrorRecord AddErrorRecord
Best Regards
Alistair Leslie-Hughes
-------------- next part --------------
>From 9dbab16ad80d4c50185f3d4be37091ffb64eaa3a Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Date: Mon, 19 Aug 2013 11:13:34 +1000
Subject: [PATCH] Implement IErrorRecord AddErrorRecord
To: wine-patches <wine-patches at winehq.org>
---
dlls/oledb32/errorinfo.c | 31 ++++++++++++++++++++++++++++---
dlls/oledb32/tests/database.c | 40 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 68 insertions(+), 3 deletions(-)
diff --git a/dlls/oledb32/errorinfo.c b/dlls/oledb32/errorinfo.c
index eef2b37..dc99a6d 100644
--- a/dlls/oledb32/errorinfo.c
+++ b/dlls/oledb32/errorinfo.c
@@ -41,7 +41,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(oledb);
struct ErrorEntry
{
struct list entry;
- ERRORINFO* info;
+ ERRORINFO info;
DISPPARAMS dispparams;
IUnknown *unknown;
DWORD lookupID;
@@ -109,6 +109,7 @@ static ULONG WINAPI IErrorInfoImpl_Release(IErrorInfo* iface)
{
ErrorInfoImpl *This = impl_from_IErrorInfo(iface);
ULONG ref = InterlockedDecrement(&This->ref);
+ struct ErrorEntry *cursor, *cursor2;
TRACE("(%p)->%u\n",This,ref+1);
@@ -117,6 +118,15 @@ static ULONG WINAPI IErrorInfoImpl_Release(IErrorInfo* iface)
SysFreeString(This->source);
SysFreeString(This->description);
SysFreeString(This->help_file);
+
+ LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, &This->errors, struct ErrorEntry, entry)
+ {
+ list_remove(&cursor->entry);
+ if(cursor->unknown)
+ IUnknown_Release(cursor->unknown);
+
+ heap_free(cursor);
+ }
heap_free(This);
}
return ref;
@@ -226,12 +236,27 @@ static HRESULT WINAPI errorrec_AddErrorRecord(IErrorRecords *iface, ERRORINFO *p
DWORD dwLookupID, DISPPARAMS *pdispparams, IUnknown *punkCustomError, DWORD dwDynamicErrorID)
{
ErrorInfoImpl *This = impl_from_IErrorRecords(iface);
+ struct ErrorEntry *entry;
- FIXME("(%p)->(%p %d %p %p %d)\n", This, pErrorInfo, dwLookupID, pdispparams, punkCustomError, dwDynamicErrorID);
+ TRACE("(%p)->(%p %d %p %p %d)\n", This, pErrorInfo, dwLookupID, pdispparams, punkCustomError, dwDynamicErrorID);
- if(pErrorInfo)
+ if(!pErrorInfo)
return E_INVALIDARG;
+ entry = heap_alloc(sizeof(*entry));
+ if(!entry)
+ return E_OUTOFMEMORY;
+
+ memcpy(&entry->info, pErrorInfo, sizeof(ERRORINFO));
+ if(pdispparams)
+ entry->dispparams = *pdispparams;
+ entry->unknown = punkCustomError;
+ if(entry->unknown)
+ IUnknown_AddRef(entry->unknown);
+ entry->lookupID = dwDynamicErrorID;
+
+ list_add_head(&This->errors, &entry->entry);
+
return S_OK;
}
diff --git a/dlls/oledb32/tests/database.c b/dlls/oledb32/tests/database.c
index 7b129b8..f41fd6c 100644
--- a/dlls/oledb32/tests/database.c
+++ b/dlls/oledb32/tests/database.c
@@ -31,6 +31,7 @@
#include "shlobj.h"
#include "msdaguid.h"
#include "initguid.h"
+#include "oledberr.h"
#include "wine/test.h"
@@ -159,6 +160,45 @@ static void test_errorinfo(void)
ok(hr == S_OK, "got %08x\n", hr);
if(hr == S_OK)
{
+ ERRORINFO info, info2, info3;
+ ULONG cnt = 0;
+
+ memset(&info, 0, sizeof(ERRORINFO));
+ info.dwMinor = 1;
+ memset(&info2, 0, sizeof(ERRORINFO));
+ info2.dwMinor = 2;
+ memset(&info3, 0, sizeof(ERRORINFO));
+
+ hr = IErrorRecords_AddErrorRecord(errrecs, NULL, 268435456, NULL, NULL, 0);
+ ok(hr == E_INVALIDARG, "got %08x\n", hr);
+
+ hr = IErrorRecords_AddErrorRecord(errrecs, &info, 1, NULL, NULL, 0);
+ ok(hr == S_OK, "got %08x\n", hr);
+
+ hr = IErrorRecords_GetRecordCount(errrecs, &cnt);
+ ok(hr == S_OK, "got %08x\n", hr);
+ ok(cnt == 1, "expected 1 got %d\n", cnt);
+
+ hr = IErrorRecords_AddErrorRecord(errrecs, &info2, 2, NULL, NULL, 0);
+ ok(hr == S_OK, "got %08x\n", hr);
+
+ hr = IErrorRecords_GetRecordCount(errrecs, &cnt);
+ ok(hr == S_OK, "got %08x\n", hr);
+ ok(cnt == 2, "expected 2 got %d\n", cnt);
+
+ hr = IErrorRecords_GetBasicErrorInfo(errrecs, 0, NULL);
+ ok(hr == E_INVALIDARG, "got %08x\n", hr);
+
+ hr = IErrorRecords_GetBasicErrorInfo(errrecs, 100, &info3);
+ ok(hr == DB_E_BADRECORDNUM, "got %08x\n", hr);
+
+ hr = IErrorRecords_GetBasicErrorInfo(errrecs, 0, &info3);
+ todo_wine ok(hr == S_OK, "got %08x\n", hr);
+ if(hr == S_OK)
+ {
+ ok(info3.dwMinor == 2, "expected 2 got %d\n", info3.dwMinor);
+ }
+
IErrorRecords_Release(errrecs);
}
--
1.8.1.2
More information about the wine-patches
mailing list