Commit 669b0a52 authored by Juan Lang's avatar Juan Lang Committed by Alexandre Julliard

rsaenh: Use Interlocked functions for reference counting.

parent eb3028ac
...@@ -253,7 +253,7 @@ int alloc_handle(HANDLETABLE *lpTable, OBJECTHDR *lpObject, unsigned int *lpHand ...@@ -253,7 +253,7 @@ int alloc_handle(HANDLETABLE *lpTable, OBJECTHDR *lpObject, unsigned int *lpHand
lpTable->paEntries[lpTable->iFirstFree].pObject = lpObject; lpTable->paEntries[lpTable->iFirstFree].pObject = lpObject;
lpTable->iFirstFree = lpTable->paEntries[lpTable->iFirstFree].iNextFree; lpTable->iFirstFree = lpTable->paEntries[lpTable->iFirstFree].iNextFree;
lpObject->refcount++; InterlockedIncrement(&lpObject->refcount);
ret = 1; ret = 1;
exit: exit:
...@@ -296,10 +296,12 @@ int release_handle(HANDLETABLE *lpTable, unsigned int handle, DWORD dwType) ...@@ -296,10 +296,12 @@ int release_handle(HANDLETABLE *lpTable, unsigned int handle, DWORD dwType)
goto exit; goto exit;
pObject = lpTable->paEntries[index].pObject; pObject = lpTable->paEntries[index].pObject;
pObject->refcount--; if (InterlockedDecrement(&pObject->refcount) == 0)
if (pObject->refcount == 0) {
TRACE("destroying handle %d\n", handle);
if (pObject->destructor) if (pObject->destructor)
pObject->destructor(pObject); pObject->destructor(pObject);
}
lpTable->paEntries[index].pObject = NULL; lpTable->paEntries[index].pObject = NULL;
lpTable->paEntries[index].iNextFree = lpTable->iFirstFree; lpTable->paEntries[index].iNextFree = lpTable->iFirstFree;
......
...@@ -36,7 +36,7 @@ typedef void (*DESTRUCTOR)(OBJECTHDR *object); ...@@ -36,7 +36,7 @@ typedef void (*DESTRUCTOR)(OBJECTHDR *object);
struct tagOBJECTHDR struct tagOBJECTHDR
{ {
DWORD dwType; DWORD dwType;
UINT refcount; LONG refcount;
DESTRUCTOR destructor; DESTRUCTOR destructor;
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment