MLANG: use Interlocked* in AddRef and Release

Mike McCormack mike at codeweavers.com
Tue Sep 14 04:56:40 CDT 2004


ChangeLog:
* use Interlocked* functions in AddRef and Release
-------------- next part --------------
Index: dlls/mlang/mlang.c
===================================================================
RCS file: /home/wine/wine/dlls/mlang/mlang.c,v
retrieving revision 1.11
diff -u -r1.11 mlang.c
--- dlls/mlang/mlang.c	6 Sep 2004 20:34:29 -0000	1.11
+++ dlls/mlang/mlang.c	14 Sep 2004 08:18:40 -0000
@@ -624,13 +624,13 @@
 
 static ULONG WINAPI MLANGCF_AddRef(LPCLASSFACTORY iface) {
     IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
-    return ++(This->ref);
+    return InterlockedIncrement(&This->ref);
 }
 
 static ULONG WINAPI MLANGCF_Release(LPCLASSFACTORY iface) {
     IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
 
-    ULONG ref = --This->ref;
+    ULONG ref = InterlockedDecrement(&This->ref);
 
     if (ref == 0)
     {
@@ -733,12 +733,12 @@
 
 static ULONG WINAPI MLang_AddRef( MLang_impl* This)
 {
-    return ++(This->ref);
+    return InterlockedIncrement(&This->ref);
 }
 
 static ULONG WINAPI MLang_Release( MLang_impl* This )
 {
-    ULONG ref = --This->ref;
+    ULONG ref = InterlockedDecrement(&This->ref);
 
     TRACE("%p ref = %ld\n", This, ref);
     if (ref == 0)
@@ -823,14 +823,14 @@
         IEnumCodePage* iface)
 {
     ICOM_THIS_MULTI(EnumCodePage_impl, vtbl_IEnumCodePage, iface);
-    return ++(This->ref);
+    return InterlockedIncrement(&This->ref);
 }
 
 static ULONG WINAPI fnIEnumCodePage_Release(
         IEnumCodePage* iface)
 {
     ICOM_THIS_MULTI(EnumCodePage_impl, vtbl_IEnumCodePage, iface);
-    ULONG ref = --This->ref;
+    ULONG ref = InterlockedIncrement(&This->ref);
 
     TRACE("%p ref = %ld\n", This, ref);
     if (ref == 0)
@@ -1009,14 +1009,14 @@
         IEnumScript* iface)
 {
     ICOM_THIS_MULTI(EnumScript_impl, vtbl_IEnumScript, iface);
-    return ++(This->ref);
+    return InterlockedIncrement(&This->ref);
 }
 
 static ULONG WINAPI fnIEnumScript_Release(
         IEnumScript* iface)
 {
     ICOM_THIS_MULTI(EnumScript_impl, vtbl_IEnumScript, iface);
-    ULONG ref = --This->ref;
+    ULONG ref = InterlockedDecrement(&This->ref);
 
     TRACE("%p ref = %ld\n", This, ref);
     if (ref == 0)


More information about the wine-patches mailing list