From 669b0a52268ee116fee74bc2ae73e89e65632546 Mon Sep 17 00:00:00 2001 From: Juan Lang Date: Fri, 28 Jul 2006 07:46:11 -0700 Subject: [PATCH] rsaenh: Use Interlocked functions for reference counting. --- dlls/rsaenh/handle.c | 8 +++++--- dlls/rsaenh/handle.h | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/dlls/rsaenh/handle.c b/dlls/rsaenh/handle.c index 01746a6e07..d924c2d258 100644 --- a/dlls/rsaenh/handle.c +++ b/dlls/rsaenh/handle.c @@ -253,7 +253,7 @@ int alloc_handle(HANDLETABLE *lpTable, OBJECTHDR *lpObject, unsigned int *lpHand lpTable->paEntries[lpTable->iFirstFree].pObject = lpObject; lpTable->iFirstFree = lpTable->paEntries[lpTable->iFirstFree].iNextFree; - lpObject->refcount++; + InterlockedIncrement(&lpObject->refcount); ret = 1; exit: @@ -296,10 +296,12 @@ int release_handle(HANDLETABLE *lpTable, unsigned int handle, DWORD dwType) goto exit; pObject = lpTable->paEntries[index].pObject; - pObject->refcount--; - if (pObject->refcount == 0) + if (InterlockedDecrement(&pObject->refcount) == 0) + { + TRACE("destroying handle %d\n", handle); if (pObject->destructor) pObject->destructor(pObject); + } lpTable->paEntries[index].pObject = NULL; lpTable->paEntries[index].iNextFree = lpTable->iFirstFree; diff --git a/dlls/rsaenh/handle.h b/dlls/rsaenh/handle.h index 14febf916f..6fa96398da 100644 --- a/dlls/rsaenh/handle.h +++ b/dlls/rsaenh/handle.h @@ -36,7 +36,7 @@ typedef void (*DESTRUCTOR)(OBJECTHDR *object); struct tagOBJECTHDR { DWORD dwType; - UINT refcount; + LONG refcount; DESTRUCTOR destructor; };