/***************************************************************************** * IDirectDrawPaletteImpl::Release * * Reduces the refcount. If the refcount falls to 0, the object is destroyed * * Returns: * The new refcount * *****************************************************************************/ static ULONG WINAPI ddraw_palette_Release(IDirectDrawPalette *iface) { struct ddraw_palette *palette = impl_from_IDirectDrawPalette(iface); ULONG ref = InterlockedDecrement(&palette->ref); TRACE("%p decreasing refcount to %u.\n", palette, ref); if (ref == 0) { wined3d_mutex_lock(); wined3d_palette_decref(palette->wined3d_palette); if ((palette->flags & DDPCAPS_PRIMARYSURFACE) && palette->ddraw->primary) palette->ddraw->primary->palette = NULL; if (palette->ifaceToRelease) IUnknown_Release(palette->ifaceToRelease); wined3d_mutex_unlock(); HeapFree(GetProcessHeap(), 0, palette); } return ref; }
/***************************************************************************** * IDirectDrawPaletteImpl::Release * * Reduces the refcount. If the refcount falls to 0, the object is destroyed * * Returns: * The new refcount * *****************************************************************************/ static ULONG WINAPI IDirectDrawPaletteImpl_Release(IDirectDrawPalette *iface) { IDirectDrawPaletteImpl *This = impl_from_IDirectDrawPalette(iface); ULONG ref = InterlockedDecrement(&This->ref); TRACE("%p decreasing refcount to %u.\n", This, ref); if (ref == 0) { EnterCriticalSection(&ddraw_cs); wined3d_palette_decref(This->wineD3DPalette); if(This->ifaceToRelease) { IUnknown_Release(This->ifaceToRelease); } LeaveCriticalSection(&ddraw_cs); HeapFree(GetProcessHeap(), 0, This); } return ref; }