avifil32: use InterlockedDecrement and InterlockedIncrement instead of ++/--

Robert Shearman rob at codeweavers.com
Thu Sep 16 05:17:48 CDT 2004


James Hawkins wrote:

>Changelog
>    * use InterlockedDecrement and InterlockedIncrement instead of ++/--
>
>  
>
>------------------------------------------------------------------------
>
>Index: dlls/avifil32/avifile.c
>===================================================================
>RCS file: /home/wine/wine/dlls/avifil32/avifile.c,v
>retrieving revision 1.48
>diff -u -r1.48 avifile.c
>--- dlls/avifil32/avifile.c	6 Sep 2004 21:34:26 -0000	1.48
>+++ dlls/avifil32/avifile.c	16 Sep 2004 01:48:46 -0000
>@@ -284,7 +284,7 @@
>   IAVIFileImpl *This = (IAVIFileImpl *)iface;
> 
>   TRACE("(%p) -> %ld\n", iface, This->ref + 1);
>-  return ++(This->ref);
>+  return InterlockedIncrement(&This->ref);
> }
> 
> static ULONG WINAPI IAVIFile_fnRelease(IAVIFile *iface)
>@@ -294,7 +294,7 @@
> 
>   TRACE("(%p) -> %ld\n", iface, This->ref - 1);
> 
>-  if (!--(This->ref)) {
>+  if (!InterlockedDecrement(&This->ref)) {
>
A small nitpick, but the correct way implement the Release function is this:
ULONG uRefs = InterlockedDecrement(&This->ref);
if (!uRefs)
    /* Free stuff */
return uRefs;

>     if (This->fDirty) {
>       /* need to write headers to file */
>       AVIFILE_SaveFile(This);
>@@ -743,7 +743,7 @@
>   if (This->paf != NULL)
>     IAVIFile_AddRef((PAVIFILE)This->paf);
> 
>-  return ++(This->ref);
>+  return InterlockedIncrement(&This->ref);
> }
> 
> static ULONG WINAPI IAVIStream_fnRelease(IAVIStream* iface)
>@@ -758,7 +758,7 @@
>     return 0;
>   }
> 
>-  This->ref--;
>+  InterlockedDecrement(&This->ref);
> 
>   if (This->paf != NULL)
>     IAVIFile_Release((PAVIFILE)This->paf);
>  
>





More information about the wine-devel mailing list