2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
11 #include <afs/param.h>
20 * ROUTINES ___________________________________________________________________
25 *** InterlockedIncrementByWindow
26 *** InterlockedDecrementByWindow
28 * Associates a zero-initialized LONG with an HWND, and calls Interlocked*()
33 #define cREALLOC_WINDOWLIST 16
39 } *aWindowList = NULL;
41 static size_t cWindowList = 0;
42 static LPCRITICAL_SECTION pcsWindowList = NULL;
44 LONG *FindLongByWindow (HWND hWnd)
48 if (pcsWindowList == NULL)
50 pcsWindowList = New (CRITICAL_SECTION);
51 InitializeCriticalSection (pcsWindowList);
54 EnterCriticalSection (pcsWindowList);
57 for (ii = 0; !lpdw && ii < cWindowList; ++ii)
59 if (aWindowList[ ii ].hWnd == hWnd)
60 lpdw = &aWindowList[ ii ].dw;
62 if (ii == cWindowList)
64 if (REALLOC( aWindowList, cWindowList, 1+ii, cREALLOC_WINDOWLIST ))
66 aWindowList[ ii ].hWnd = hWnd;
67 aWindowList[ ii ].dw = 0;
68 lpdw = &aWindowList[ ii ].dw;
72 LeaveCriticalSection (pcsWindowList);
76 LONG InterlockedIncrementByWindow (HWND hWnd)
79 if ((lpdw = FindLongByWindow (hWnd)) == NULL)
81 return InterlockedIncrement (lpdw);
84 LONG InterlockedDecrementByWindow (HWND hWnd)
87 if ((lpdw = FindLongByWindow (hWnd)) == NULL)
89 return InterlockedDecrement (lpdw);