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
14 #include <afs/param.h>
23 * ROUTINES ___________________________________________________________________
28 *** InterlockedIncrementByWindow
29 *** InterlockedDecrementByWindow
31 * Associates a zero-initialized LONG with an HWND, and calls Interlocked*()
36 #define cREALLOC_WINDOWLIST 16
42 } *aWindowList = NULL;
44 static size_t cWindowList = 0;
45 static LPCRITICAL_SECTION pcsWindowList = NULL;
47 LONG *FindLongByWindow (HWND hWnd)
51 if (pcsWindowList == NULL)
53 pcsWindowList = New (CRITICAL_SECTION);
54 InitializeCriticalSection (pcsWindowList);
57 EnterCriticalSection (pcsWindowList);
60 for (ii = 0; !lpdw && ii < cWindowList; ++ii)
62 if (aWindowList[ ii ].hWnd == hWnd)
63 lpdw = &aWindowList[ ii ].dw;
65 if (ii == cWindowList)
67 if (REALLOC( aWindowList, cWindowList, 1+ii, cREALLOC_WINDOWLIST ))
69 aWindowList[ ii ].hWnd = hWnd;
70 aWindowList[ ii ].dw = 0;
71 lpdw = &aWindowList[ ii ].dw;
75 LeaveCriticalSection (pcsWindowList);
79 LONG InterlockedIncrementByWindow (HWND hWnd)
82 if ((lpdw = FindLongByWindow (hWnd)) == NULL)
84 return InterlockedIncrement (lpdw);
87 LONG InterlockedDecrementByWindow (HWND hWnd)
90 if ((lpdw = FindLongByWindow (hWnd)) == NULL)
92 return InterlockedDecrement (lpdw);