Huw Davies : ole32: Add a ref-count to the handle structure.
Alexandre Julliard
julliard at winehq.org
Tue Aug 11 16:26:50 CDT 2020
Module: wine
Branch: master
Commit: fe3421ba2c863993bb411b0bd4d5b6b2ed4b956e
URL: https://source.winehq.org/git/wine.git/?a=commit;h=fe3421ba2c863993bb411b0bd4d5b6b2ed4b956e
Author: Huw Davies <huw at codeweavers.com>
Date: Tue Aug 11 12:49:50 2020 +0100
ole32: Add a ref-count to the handle structure.
Based on a patch by Dmitry Timoshkov.
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ole32/hglobalstream.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/dlls/ole32/hglobalstream.c b/dlls/ole32/hglobalstream.c
index 300119dcc7..8fd1e03913 100644
--- a/dlls/ole32/hglobalstream.c
+++ b/dlls/ole32/hglobalstream.c
@@ -45,6 +45,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(storage);
struct handle_wrapper
{
+ LONG ref;
HGLOBAL hglobal;
ULONG size;
BOOL delete_on_release;
@@ -52,8 +53,13 @@ struct handle_wrapper
static void handle_release(struct handle_wrapper *handle)
{
+ ULONG ref = InterlockedDecrement(&handle->ref);
+
+ if (!ref)
+ {
if (handle->delete_on_release) GlobalFree(handle->hglobal);
HeapFree(GetProcessHeap(), 0, handle);
+ }
}
static struct handle_wrapper *handle_create(HGLOBAL hglobal, BOOL delete_on_release)
@@ -70,6 +76,7 @@ static struct handle_wrapper *handle_create(HGLOBAL hglobal, BOOL delete_on_rele
HeapFree(GetProcessHeap(), 0, handle);
return NULL;
}
+ handle->ref = 1;
handle->hglobal = hglobal;
handle->size = GlobalSize(hglobal);
handle->delete_on_release = delete_on_release;
More information about the wine-cvs
mailing list