Index: dlls/winmm/lolvldrv.c =================================================================== RCS file: /home/wine/wine/dlls/winmm/lolvldrv.c,v retrieving revision 1.22 diff -u -r1.22 lolvldrv.c --- dlls/winmm/lolvldrv.c 2001/05/22 19:19:50 1.22 +++ dlls/winmm/lolvldrv.c 2001/07/23 23:45:04 @@ -2091,21 +2091,22 @@ DWORD* dwCallback, DWORD* dwInstance, BOOL bFrom32) { LPWINE_MLD mld; + UINT idx; mld = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size); if (!mld) return NULL; /* find an empty slot in MM_MLDrvs table */ - for (*hndl = 0; *hndl < MAX_MM_MLDRVS; (*hndl)++) { - if (!MM_MLDrvs[*hndl]) break; + for (idx = 0; idx < MAX_MM_MLDRVS; idx++) { + if (!MM_MLDrvs[idx]) break; } - if (*hndl == MAX_MM_MLDRVS) { + if (idx == MAX_MM_MLDRVS) { /* the MM_MLDrvs table could be made growable in the future if needed */ ERR("Too many open drivers\n"); return NULL; } - MM_MLDrvs[*hndl] = mld; - *hndl |= 0x8000; + MM_MLDrvs[idx] = mld; + *hndl = (HANDLE)(idx | 0x8000); mld->type = type; if ((UINT)*hndl < MMDRV_GetNum(type) || HIWORD(*hndl) != 0) { @@ -2133,8 +2134,8 @@ */ void MMDRV_Free(HANDLE hndl, LPWINE_MLD mld) { - if (hndl & 0x8000) { - unsigned idx = hndl & ~0x8000; + if ((UINT)hndl & 0x8000) { + unsigned idx = (UINT)hndl & ~0x8000; if (idx < sizeof(MM_MLDrvs) / sizeof(MM_MLDrvs[0])) { MM_MLDrvs[idx] = NULL; HeapFree(GetProcessHeap(), 0, mld); @@ -2214,23 +2215,24 @@ LPWINE_MLD MMDRV_Get(HANDLE hndl, UINT type, BOOL bCanBeID) { LPWINE_MLD mld = NULL; + UINT idx=(UINT)hndl; assert(type < MMDRV_MAX); - if ((UINT)hndl >= llTypes[type].wMaxId && - hndl != (UINT16)-1 && hndl != (UINT)-1) { - if (hndl & 0x8000) { - hndl &= ~0x8000; - if (hndl < sizeof(MM_MLDrvs) / sizeof(MM_MLDrvs[0])) { + if (idx >= llTypes[type].wMaxId && + idx != (UINT16)-1 && idx != (UINT)-1) { + if (idx & 0x8000) { + idx &= ~0x8000; + if (idx < sizeof(MM_MLDrvs) / sizeof(MM_MLDrvs[0])) { mld = MM_MLDrvs[hndl]; if (!mld || !HeapValidate(GetProcessHeap(), 0, mld) || mld->type != type) mld = NULL; } - hndl |= 0x8000; + idx |= 0x8000; } } if (mld == NULL && bCanBeID) { - mld = MMDRV_GetByID((UINT)hndl, type); + mld = MMDRV_GetByID(idx, type); } return mld; }