[PATCH v3 4/5] windows.media.speech: Simplify error handling in async_operation_create.
Rémi Bernon
wine at gitlab.winehq.org
Wed Apr 27 16:11:23 CDT 2022
From: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/windows.media.speech/async.c | 20 +++++---------------
1 file changed, 5 insertions(+), 15 deletions(-)
diff --git a/dlls/windows.media.speech/async.c b/dlls/windows.media.speech/async.c
index 3b532502ea2..418e903476e 100644
--- a/dlls/windows.media.speech/async.c
+++ b/dlls/windows.media.speech/async.c
@@ -370,16 +370,9 @@ static void CALLBACK async_run_cb(TP_CALLBACK_INSTANCE *instance, void *data, TP
HRESULT async_operation_create( const GUID *iid, IInspectable *invoker, async_operation_callback callback, IAsyncOperation_IInspectable **out )
{
struct async_operation *impl;
- HRESULT hr;
*out = NULL;
-
- if (!(impl = calloc(1, sizeof(*impl))))
- {
- hr = E_OUTOFMEMORY;
- goto error;
- }
-
+ if (!(impl = calloc(1, sizeof(*impl)))) return E_OUTOFMEMORY;
impl->IAsyncOperation_IInspectable_iface.lpVtbl = &async_operation_vtbl;
impl->IAsyncInfo_iface.lpVtbl = &async_operation_info_vtbl;
impl->iid = iid;
@@ -389,11 +382,10 @@ HRESULT async_operation_create( const GUID *iid, IInspectable *invoker, async_op
impl->callback = callback;
impl->status = Started;
- IAsyncOperation_IInspectable_AddRef(&impl->IAsyncOperation_IInspectable_iface); /* AddRef to keep the obj alive in the callback. */
if (!(impl->async_run_work = CreateThreadpoolWork(async_run_cb, &impl->IAsyncOperation_IInspectable_iface, NULL)))
{
- hr = HRESULT_FROM_WIN32(GetLastError());
- goto error;
+ free(impl);
+ return HRESULT_FROM_WIN32(GetLastError());
}
if (invoker) IInspectable_AddRef((impl->invoker = invoker));
@@ -401,13 +393,11 @@ HRESULT async_operation_create( const GUID *iid, IInspectable *invoker, async_op
InitializeCriticalSection(&impl->cs);
impl->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": async_operation.cs");
+ /* AddRef to keep the obj alive in the callback. */
+ IAsyncOperation_IInspectable_AddRef(&impl->IAsyncOperation_IInspectable_iface);
SubmitThreadpoolWork(impl->async_run_work);
*out = &impl->IAsyncOperation_IInspectable_iface;
TRACE("created %p\n", *out);
return S_OK;
-
-error:
- free(impl);
- return hr;
}
--
GitLab
https://gitlab.winehq.org/wine/wine/-/merge_requests/5
More information about the wine-devel
mailing list