Commit 43f01a2f authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

winmm: Use CRT allocation functions.

parent 38111eb3
...@@ -286,7 +286,7 @@ LPWINE_DRIVER DRIVER_TryOpenDriver32(LPCWSTR fn, LPARAM lParam2) ...@@ -286,7 +286,7 @@ LPWINE_DRIVER DRIVER_TryOpenDriver32(LPCWSTR fn, LPARAM lParam2)
if (*ptr == '\0') ptr = NULL; if (*ptr == '\0') ptr = NULL;
} }
lpDrv = HeapAlloc(GetProcessHeap(), 0, sizeof(WINE_DRIVER)); lpDrv = malloc(sizeof(WINE_DRIVER));
if (lpDrv == NULL) {cause = "OOM"; goto exit;} if (lpDrv == NULL) {cause = "OOM"; goto exit;}
if ((hModule = LoadLibraryW(fn)) == 0) {cause = "Not a 32 bit lib"; goto exit;} if ((hModule = LoadLibraryW(fn)) == 0) {cause = "Not a 32 bit lib"; goto exit;}
...@@ -329,7 +329,7 @@ LPWINE_DRIVER DRIVER_TryOpenDriver32(LPCWSTR fn, LPARAM lParam2) ...@@ -329,7 +329,7 @@ LPWINE_DRIVER DRIVER_TryOpenDriver32(LPCWSTR fn, LPARAM lParam2)
return lpDrv; return lpDrv;
exit: exit:
FreeLibrary(hModule); FreeLibrary(hModule);
HeapFree(GetProcessHeap(), 0, lpDrv); free(lpDrv);
TRACE("Unable to load 32 bit module %s: %s\n", debugstr_w(fn), cause); TRACE("Unable to load 32 bit module %s: %s\n", debugstr_w(fn), cause);
return NULL; return NULL;
} }
...@@ -351,7 +351,7 @@ HDRVR WINAPI OpenDriverA(LPCSTR lpDriverName, LPCSTR lpSectionName, LPARAM lPara ...@@ -351,7 +351,7 @@ HDRVR WINAPI OpenDriverA(LPCSTR lpDriverName, LPCSTR lpSectionName, LPARAM lPara
if (lpDriverName) if (lpDriverName)
{ {
len = MultiByteToWideChar( CP_ACP, 0, lpDriverName, -1, NULL, 0 ); len = MultiByteToWideChar( CP_ACP, 0, lpDriverName, -1, NULL, 0 );
dn = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ); dn = malloc( len * sizeof(WCHAR) );
if (!dn) goto done; if (!dn) goto done;
MultiByteToWideChar( CP_ACP, 0, lpDriverName, -1, dn, len ); MultiByteToWideChar( CP_ACP, 0, lpDriverName, -1, dn, len );
} }
...@@ -359,7 +359,7 @@ HDRVR WINAPI OpenDriverA(LPCSTR lpDriverName, LPCSTR lpSectionName, LPARAM lPara ...@@ -359,7 +359,7 @@ HDRVR WINAPI OpenDriverA(LPCSTR lpDriverName, LPCSTR lpSectionName, LPARAM lPara
if (lpSectionName) if (lpSectionName)
{ {
len = MultiByteToWideChar( CP_ACP, 0, lpSectionName, -1, NULL, 0 ); len = MultiByteToWideChar( CP_ACP, 0, lpSectionName, -1, NULL, 0 );
sn = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ); sn = malloc( len * sizeof(WCHAR) );
if (!sn) goto done; if (!sn) goto done;
MultiByteToWideChar( CP_ACP, 0, lpSectionName, -1, sn, len ); MultiByteToWideChar( CP_ACP, 0, lpSectionName, -1, sn, len );
} }
...@@ -367,8 +367,8 @@ HDRVR WINAPI OpenDriverA(LPCSTR lpDriverName, LPCSTR lpSectionName, LPARAM lPara ...@@ -367,8 +367,8 @@ HDRVR WINAPI OpenDriverA(LPCSTR lpDriverName, LPCSTR lpSectionName, LPARAM lPara
ret = OpenDriver(dn, sn, lParam); ret = OpenDriver(dn, sn, lParam);
done: done:
HeapFree(GetProcessHeap(), 0, dn); free(dn);
HeapFree(GetProcessHeap(), 0, sn); free(sn);
return ret; return ret;
} }
...@@ -439,11 +439,11 @@ LRESULT WINAPI CloseDriver(HDRVR hDrvr, LPARAM lParam1, LPARAM lParam2) ...@@ -439,11 +439,11 @@ LRESULT WINAPI CloseDriver(HDRVR hDrvr, LPARAM lParam1, LPARAM lParam2)
DRIVER_SendMessage(lpDrv0, DRV_CLOSE, 0, 0); DRIVER_SendMessage(lpDrv0, DRV_CLOSE, 0, 0);
DRIVER_RemoveFromList(lpDrv0); DRIVER_RemoveFromList(lpDrv0);
FreeLibrary(lpDrv0->hModule); FreeLibrary(lpDrv0->hModule);
HeapFree(GetProcessHeap(), 0, lpDrv0); free(lpDrv0);
} }
FreeLibrary(lpDrv->hModule); FreeLibrary(lpDrv->hModule);
HeapFree(GetProcessHeap(), 0, lpDrv); free(lpDrv);
ret = TRUE; ret = TRUE;
} }
else else
......
...@@ -137,7 +137,7 @@ LPWINE_MLD MMDRV_Alloc(UINT size, UINT type, LPHANDLE hndl, DWORD* dwFlags, ...@@ -137,7 +137,7 @@ LPWINE_MLD MMDRV_Alloc(UINT size, UINT type, LPHANDLE hndl, DWORD* dwFlags,
TRACE("(%d, %04x, %p, %p, %p, %p)\n", TRACE("(%d, %04x, %p, %p, %p, %p)\n",
size, type, hndl, dwFlags, dwCallback, dwInstance); size, type, hndl, dwFlags, dwCallback, dwInstance);
mld = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size); mld = calloc(1, size);
if (!mld) return NULL; if (!mld) return NULL;
/* find an empty slot in MM_MLDrvs table */ /* find an empty slot in MM_MLDrvs table */
...@@ -146,7 +146,7 @@ LPWINE_MLD MMDRV_Alloc(UINT size, UINT type, LPHANDLE hndl, DWORD* dwFlags, ...@@ -146,7 +146,7 @@ LPWINE_MLD MMDRV_Alloc(UINT size, UINT type, LPHANDLE hndl, DWORD* dwFlags,
if (i == ARRAY_SIZE(MM_MLDrvs)) { if (i == ARRAY_SIZE(MM_MLDrvs)) {
/* the MM_MLDrvs table could be made growable in the future if needed */ /* the MM_MLDrvs table could be made growable in the future if needed */
ERR("Too many open drivers\n"); ERR("Too many open drivers\n");
HeapFree(GetProcessHeap(), 0, mld); free(mld);
return NULL; return NULL;
} }
MM_MLDrvs[i] = mld; MM_MLDrvs[i] = mld;
...@@ -179,7 +179,7 @@ void MMDRV_Free(HANDLE hndl, LPWINE_MLD mld) ...@@ -179,7 +179,7 @@ void MMDRV_Free(HANDLE hndl, LPWINE_MLD mld)
UINT_PTR idx = (UINT_PTR)hndl & ~0x8000; UINT_PTR idx = (UINT_PTR)hndl & ~0x8000;
if (idx < ARRAY_SIZE(MM_MLDrvs)) { if (idx < ARRAY_SIZE(MM_MLDrvs)) {
MM_MLDrvs[idx] = NULL; MM_MLDrvs[idx] = NULL;
HeapFree(GetProcessHeap(), 0, mld); free(mld);
return; return;
} }
} }
...@@ -372,14 +372,9 @@ static BOOL MMDRV_InitPerType(LPWINE_MM_DRIVER lpDrv, UINT type, UINT wMsg) ...@@ -372,14 +372,9 @@ static BOOL MMDRV_InitPerType(LPWINE_MM_DRIVER lpDrv, UINT type, UINT wMsg)
part->nIDMin, part->nIDMax, llTypes[type].wMaxId, part->nIDMin, part->nIDMax, llTypes[type].wMaxId,
lpDrv->drvname, llTypes[type].typestr); lpDrv->drvname, llTypes[type].typestr);
/* realloc translation table */ /* realloc translation table */
if (llTypes[type].lpMlds) { mem = llTypes[type].lpMlds ? llTypes[type].lpMlds - 1 : NULL;
mem = llTypes[type].lpMlds - 1; mem = realloc(mem, sizeof(WINE_MLD) * (llTypes[type].wMaxId + 1));
mem = HeapReAlloc(GetProcessHeap(), 0, mem, sizeof(WINE_MLD) * (llTypes[type].wMaxId + 1)); llTypes[type].lpMlds = mem + 1;
llTypes[type].lpMlds = mem + 1;
} else {
mem = HeapAlloc(GetProcessHeap(), 0, sizeof(WINE_MLD) * (llTypes[type].wMaxId + 1));
llTypes[type].lpMlds = mem + 1;
}
/* re-build the translation table */ /* re-build the translation table */
if (lpDrv->bIsMapper) { if (lpDrv->bIsMapper) {
...@@ -463,7 +458,7 @@ static BOOL MMDRV_Install(LPCSTR drvRegName, LPCSTR drvFileName, BOOL bIsMapper) ...@@ -463,7 +458,7 @@ static BOOL MMDRV_Install(LPCSTR drvRegName, LPCSTR drvFileName, BOOL bIsMapper)
* I don't have any clue for PE drvs * I don't have any clue for PE drvs
*/ */
lpDrv->bIsMapper = bIsMapper; lpDrv->bIsMapper = bIsMapper;
lpDrv->drvname = strcpy(HeapAlloc(GetProcessHeap(), 0, strlen(drvRegName) + 1), drvRegName); lpDrv->drvname = strdup(drvRegName);
/* Finish init and get the count of the devices */ /* Finish init and get the count of the devices */
i = 0; i = 0;
...@@ -476,7 +471,7 @@ static BOOL MMDRV_Install(LPCSTR drvRegName, LPCSTR drvFileName, BOOL bIsMapper) ...@@ -476,7 +471,7 @@ static BOOL MMDRV_Install(LPCSTR drvRegName, LPCSTR drvFileName, BOOL bIsMapper)
/* if all those func calls return FALSE, then the driver must be unloaded */ /* if all those func calls return FALSE, then the driver must be unloaded */
if (!i) { if (!i) {
CloseDriver(lpDrv->hDriver, 0, 0); CloseDriver(lpDrv->hDriver, 0, 0);
HeapFree(GetProcessHeap(), 0, lpDrv->drvname); free(lpDrv->drvname);
WARN("Driver initialization failed\n"); WARN("Driver initialization failed\n");
return FALSE; return FALSE;
} }
...@@ -535,12 +530,12 @@ static void MMDRV_Init(void) ...@@ -535,12 +530,12 @@ static void MMDRV_Init(void)
size = WideCharToMultiByte(CP_ACP, 0, pv.pwszVal, -1, size = WideCharToMultiByte(CP_ACP, 0, pv.pwszVal, -1,
NULL, 0, NULL, NULL); NULL, 0, NULL, NULL);
drvA = HeapAlloc(GetProcessHeap(), 0, size); drvA = malloc(size);
WideCharToMultiByte(CP_ACP, 0, pv.pwszVal, -1, drvA, size, NULL, NULL); WideCharToMultiByte(CP_ACP, 0, pv.pwszVal, -1, drvA, size, NULL, NULL);
MMDRV_Install(drvA, drvA, FALSE); MMDRV_Install(drvA, drvA, FALSE);
HeapFree(GetProcessHeap(), 0, drvA); free(drvA);
PropVariantClear(&pv); PropVariantClear(&pv);
MMDRV_Install("wavemapper", "msacm32.drv", TRUE); MMDRV_Install("wavemapper", "msacm32.drv", TRUE);
...@@ -609,15 +604,15 @@ void MMDRV_Exit(void) ...@@ -609,15 +604,15 @@ void MMDRV_Exit(void)
CloseDriver(MMDrvs[i].hDriver, 0, 0); CloseDriver(MMDrvs[i].hDriver, 0, 0);
} }
if (llTypes[MMDRV_AUX].lpMlds) if (llTypes[MMDRV_AUX].lpMlds)
HeapFree(GetProcessHeap(), 0, llTypes[MMDRV_AUX].lpMlds - 1); free(llTypes[MMDRV_AUX].lpMlds - 1);
if (llTypes[MMDRV_MIXER].lpMlds) if (llTypes[MMDRV_MIXER].lpMlds)
HeapFree(GetProcessHeap(), 0, llTypes[MMDRV_MIXER].lpMlds - 1); free(llTypes[MMDRV_MIXER].lpMlds - 1);
if (llTypes[MMDRV_MIDIIN].lpMlds) if (llTypes[MMDRV_MIDIIN].lpMlds)
HeapFree(GetProcessHeap(), 0, llTypes[MMDRV_MIDIIN].lpMlds - 1); free(llTypes[MMDRV_MIDIIN].lpMlds - 1);
if (llTypes[MMDRV_MIDIOUT].lpMlds) if (llTypes[MMDRV_MIDIOUT].lpMlds)
HeapFree(GetProcessHeap(), 0, llTypes[MMDRV_MIDIOUT].lpMlds - 1); free(llTypes[MMDRV_MIDIOUT].lpMlds - 1);
if (llTypes[MMDRV_WAVEIN].lpMlds) if (llTypes[MMDRV_WAVEIN].lpMlds)
HeapFree(GetProcessHeap(), 0, llTypes[MMDRV_WAVEIN].lpMlds - 1); free(llTypes[MMDRV_WAVEIN].lpMlds - 1);
if (llTypes[MMDRV_WAVEOUT].lpMlds) if (llTypes[MMDRV_WAVEOUT].lpMlds)
HeapFree(GetProcessHeap(), 0, llTypes[MMDRV_WAVEOUT].lpMlds - 1); free(llTypes[MMDRV_WAVEOUT].lpMlds - 1);
} }
...@@ -319,7 +319,7 @@ static LPMMIOPROC MMIO_InstallIOProc(FOURCC fccIOProc, LPMMIOPROC pIOProc, ...@@ -319,7 +319,7 @@ static LPMMIOPROC MMIO_InstallIOProc(FOURCC fccIOProc, LPMMIOPROC pIOProc,
switch (dwFlags & (MMIO_INSTALLPROC|MMIO_REMOVEPROC|MMIO_FINDPROC)) { switch (dwFlags & (MMIO_INSTALLPROC|MMIO_REMOVEPROC|MMIO_FINDPROC)) {
case MMIO_INSTALLPROC: case MMIO_INSTALLPROC:
/* Create new entry for the IOProc list */ /* Create new entry for the IOProc list */
pListNode = HeapAlloc(GetProcessHeap(), 0, sizeof(*pListNode)); pListNode = malloc(sizeof(*pListNode));
if (pListNode) { if (pListNode) {
/* Fill in this node */ /* Fill in this node */
pListNode->fourCC = fccIOProc; pListNode->fourCC = fccIOProc;
...@@ -369,7 +369,7 @@ static LPMMIOPROC MMIO_InstallIOProc(FOURCC fccIOProc, LPMMIOPROC pIOProc, ...@@ -369,7 +369,7 @@ static LPMMIOPROC MMIO_InstallIOProc(FOURCC fccIOProc, LPMMIOPROC pIOProc,
struct IOProcList* ptmpNode = *ppListNode; struct IOProcList* ptmpNode = *ppListNode;
lpProc = (*ppListNode)->pIOProc; lpProc = (*ppListNode)->pIOProc;
*ppListNode = (*ppListNode)->pNext; *ppListNode = (*ppListNode)->pNext;
HeapFree(GetProcessHeap(), 0, ptmpNode); free(ptmpNode);
} }
} }
break; break;
...@@ -498,7 +498,7 @@ static LPWINE_MMIO MMIO_Create(void) ...@@ -498,7 +498,7 @@ static LPWINE_MMIO MMIO_Create(void)
static WORD MMIO_counter = 0; static WORD MMIO_counter = 0;
LPWINE_MMIO wm; LPWINE_MMIO wm;
wm = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINE_MMIO)); wm = calloc(1, sizeof(WINE_MMIO));
if (wm) { if (wm) {
EnterCriticalSection(&WINMM_cs); EnterCriticalSection(&WINMM_cs);
/* lookup next unallocated WORD handle, with a non NULL value */ /* lookup next unallocated WORD handle, with a non NULL value */
...@@ -527,7 +527,7 @@ static BOOL MMIO_Destroy(LPWINE_MMIO wm) ...@@ -527,7 +527,7 @@ static BOOL MMIO_Destroy(LPWINE_MMIO wm)
/* ...and destroy */ /* ...and destroy */
if (*m) { if (*m) {
*m = (*m)->lpNext; *m = (*m)->lpNext;
HeapFree(GetProcessHeap(), 0, wm); free(wm);
wm = NULL; wm = NULL;
} }
LeaveCriticalSection(&WINMM_cs); LeaveCriticalSection(&WINMM_cs);
...@@ -600,7 +600,7 @@ static MMRESULT MMIO_SetBuffer(WINE_MMIO* wm, void* pchBuffer, LONG cchBuffer, ...@@ -600,7 +600,7 @@ static MMRESULT MMIO_SetBuffer(WINE_MMIO* wm, void* pchBuffer, LONG cchBuffer,
/* free previous buffer if allocated */ /* free previous buffer if allocated */
if (wm->info.dwFlags & MMIO_ALLOCBUF) { if (wm->info.dwFlags & MMIO_ALLOCBUF) {
HeapFree(GetProcessHeap(), 0, wm->info.pchBuffer); free(wm->info.pchBuffer);
wm->info.pchBuffer = NULL; wm->info.pchBuffer = NULL;
wm->info.dwFlags &= ~MMIO_ALLOCBUF; wm->info.dwFlags &= ~MMIO_ALLOCBUF;
} }
...@@ -608,7 +608,7 @@ static MMRESULT MMIO_SetBuffer(WINE_MMIO* wm, void* pchBuffer, LONG cchBuffer, ...@@ -608,7 +608,7 @@ static MMRESULT MMIO_SetBuffer(WINE_MMIO* wm, void* pchBuffer, LONG cchBuffer,
if (pchBuffer) { if (pchBuffer) {
wm->info.pchBuffer = pchBuffer; wm->info.pchBuffer = pchBuffer;
} else if (cchBuffer) { } else if (cchBuffer) {
if (!(wm->info.pchBuffer = HeapAlloc(GetProcessHeap(), 0, cchBuffer))) if (!(wm->info.pchBuffer = malloc(cchBuffer)))
return MMIOERR_OUTOFMEMORY; return MMIOERR_OUTOFMEMORY;
wm->info.dwFlags |= MMIO_ALLOCBUF; wm->info.dwFlags |= MMIO_ALLOCBUF;
} else { } else {
...@@ -722,7 +722,7 @@ static HMMIO MMIO_Open(LPSTR szFileName, MMIOINFO* refmminfo, DWORD dwOpenFlags, ...@@ -722,7 +722,7 @@ static HMMIO MMIO_Open(LPSTR szFileName, MMIOINFO* refmminfo, DWORD dwOpenFlags,
return wm->info.hmmio; return wm->info.hmmio;
error1: error1:
if (wm->info.dwFlags & MMIO_ALLOCBUF) if (wm->info.dwFlags & MMIO_ALLOCBUF)
HeapFree(GetProcessHeap(), 0, wm->info.pchBuffer); free(wm->info.pchBuffer);
if (wm->ioProc) wm->ioProc->count--; if (wm->ioProc) wm->ioProc->count--;
error2: error2:
MMIO_Destroy(wm); MMIO_Destroy(wm);
...@@ -742,14 +742,14 @@ HMMIO WINAPI mmioOpenW(LPWSTR szFileName, MMIOINFO* lpmmioinfo, ...@@ -742,14 +742,14 @@ HMMIO WINAPI mmioOpenW(LPWSTR szFileName, MMIOINFO* lpmmioinfo,
{ {
INT len = WideCharToMultiByte( CP_ACP, 0, szFileName, -1, NULL, 0, NULL, NULL ); INT len = WideCharToMultiByte( CP_ACP, 0, szFileName, -1, NULL, 0, NULL, NULL );
if (len < MAX_PATH) len = MAX_PATH; if (len < MAX_PATH) len = MAX_PATH;
szFn = HeapAlloc( GetProcessHeap(), 0, len ); szFn = malloc( len );
if (!szFn) return NULL; if (!szFn) return NULL;
WideCharToMultiByte( CP_ACP, 0, szFileName, -1, szFn, len, NULL, NULL ); WideCharToMultiByte( CP_ACP, 0, szFileName, -1, szFn, len, NULL, NULL );
} }
ret = MMIO_Open(szFn, lpmmioinfo, dwOpenFlags, TRUE); ret = MMIO_Open(szFn, lpmmioinfo, dwOpenFlags, TRUE);
HeapFree(GetProcessHeap(), 0, szFn); free(szFn);
return ret; return ret;
} }
...@@ -1401,14 +1401,14 @@ MMRESULT WINAPI mmioRenameW(LPCWSTR szFileName, LPCWSTR szNewFileName, ...@@ -1401,14 +1401,14 @@ MMRESULT WINAPI mmioRenameW(LPCWSTR szFileName, LPCWSTR szNewFileName,
if (szFileName) if (szFileName)
{ {
len = WideCharToMultiByte( CP_ACP, 0, szFileName, -1, NULL, 0, NULL, NULL ); len = WideCharToMultiByte( CP_ACP, 0, szFileName, -1, NULL, 0, NULL, NULL );
szFn = HeapAlloc( GetProcessHeap(), 0, len ); szFn = malloc( len );
if (!szFn) goto done; if (!szFn) goto done;
WideCharToMultiByte( CP_ACP, 0, szFileName, -1, szFn, len, NULL, NULL ); WideCharToMultiByte( CP_ACP, 0, szFileName, -1, szFn, len, NULL, NULL );
} }
if (szNewFileName) if (szNewFileName)
{ {
len = WideCharToMultiByte( CP_ACP, 0, szNewFileName, -1, NULL, 0, NULL, NULL ); len = WideCharToMultiByte( CP_ACP, 0, szNewFileName, -1, NULL, 0, NULL, NULL );
sznFn = HeapAlloc( GetProcessHeap(), 0, len ); sznFn = malloc( len );
if (!sznFn) goto done; if (!sznFn) goto done;
WideCharToMultiByte( CP_ACP, 0, szNewFileName, -1, sznFn, len, NULL, NULL ); WideCharToMultiByte( CP_ACP, 0, szNewFileName, -1, sznFn, len, NULL, NULL );
} }
...@@ -1416,7 +1416,7 @@ MMRESULT WINAPI mmioRenameW(LPCWSTR szFileName, LPCWSTR szNewFileName, ...@@ -1416,7 +1416,7 @@ MMRESULT WINAPI mmioRenameW(LPCWSTR szFileName, LPCWSTR szNewFileName,
ret = mmioRenameA(szFn, sznFn, lpmmioinfo, dwFlags); ret = mmioRenameA(szFn, sznFn, lpmmioinfo, dwFlags);
done: done:
HeapFree(GetProcessHeap(),0,szFn); free(szFn);
HeapFree(GetProcessHeap(),0,sznFn); free(sznFn);
return ret; return ret;
} }
...@@ -201,8 +201,8 @@ static void PlaySound_Free(WINE_PLAYSOUND* wps) ...@@ -201,8 +201,8 @@ static void PlaySound_Free(WINE_PLAYSOUND* wps)
PlaySoundCurrent = NULL; PlaySoundCurrent = NULL;
SetEvent(psLastEvent); SetEvent(psLastEvent);
LeaveCriticalSection(&WINMM_cs); LeaveCriticalSection(&WINMM_cs);
if (wps->bAlloc) HeapFree(GetProcessHeap(), 0, (void*)wps->pszSound); if (wps->bAlloc) free((void*)wps->pszSound);
HeapFree(GetProcessHeap(), 0, wps); free(wps);
} }
static WINE_PLAYSOUND* PlaySound_Alloc(const void* pszSound, HMODULE hmod, static WINE_PLAYSOUND* PlaySound_Alloc(const void* pszSound, HMODULE hmod,
...@@ -210,7 +210,7 @@ static WINE_PLAYSOUND* PlaySound_Alloc(const void* pszSound, HMODULE hmod, ...@@ -210,7 +210,7 @@ static WINE_PLAYSOUND* PlaySound_Alloc(const void* pszSound, HMODULE hmod,
{ {
WINE_PLAYSOUND* wps; WINE_PLAYSOUND* wps;
wps = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*wps)); wps = calloc(1, sizeof(*wps));
if (!wps) return NULL; if (!wps) return NULL;
wps->hMod = hmod; wps->hMod = hmod;
...@@ -221,10 +221,8 @@ static WINE_PLAYSOUND* PlaySound_Alloc(const void* pszSound, HMODULE hmod, ...@@ -221,10 +221,8 @@ static WINE_PLAYSOUND* PlaySound_Alloc(const void* pszSound, HMODULE hmod,
{ {
if (fdwSound & SND_ASYNC) if (fdwSound & SND_ASYNC)
{ {
LPWSTR sound = HeapAlloc(GetProcessHeap(), 0, wps->pszSound = wcsdup(pszSound);
(lstrlenW(pszSound)+1) * sizeof(WCHAR)); if (!wps->pszSound) goto oom_error;
if (!sound) goto oom_error;
wps->pszSound = lstrcpyW(sound, pszSound);
wps->bAlloc = TRUE; wps->bAlloc = TRUE;
} }
else else
...@@ -244,8 +242,8 @@ static WINE_PLAYSOUND* PlaySound_Alloc(const void* pszSound, HMODULE hmod, ...@@ -244,8 +242,8 @@ static WINE_PLAYSOUND* PlaySound_Alloc(const void* pszSound, HMODULE hmod,
return wps; return wps;
oom_error: oom_error:
if (wps->bAlloc) HeapFree(GetProcessHeap(), 0, (void*)wps->pszSound); if (wps->bAlloc) free((void*)wps->pszSound);
HeapFree(GetProcessHeap(), 0, wps); free(wps);
return NULL; return NULL;
} }
...@@ -359,7 +357,7 @@ static DWORD WINAPI proc_PlaySound(LPVOID arg) ...@@ -359,7 +357,7 @@ static DWORD WINAPI proc_PlaySound(LPVOID arg)
TRACE("Chunk Found ckid=%.4s fccType=%08lx cksize=%08lX\n", TRACE("Chunk Found ckid=%.4s fccType=%08lx cksize=%08lX\n",
(LPSTR)&mmckInfo.ckid, mmckInfo.fccType, mmckInfo.cksize); (LPSTR)&mmckInfo.ckid, mmckInfo.fccType, mmckInfo.cksize);
lpWaveFormat = HeapAlloc(GetProcessHeap(), 0, mmckInfo.cksize); lpWaveFormat = malloc(mmckInfo.cksize);
if (!lpWaveFormat) if (!lpWaveFormat)
goto errCleanUp; goto errCleanUp;
r = mmioRead(hmmio, (HPSTR)lpWaveFormat, mmckInfo.cksize); r = mmioRead(hmmio, (HPSTR)lpWaveFormat, mmckInfo.cksize);
...@@ -394,7 +392,7 @@ static DWORD WINAPI proc_PlaySound(LPVOID arg) ...@@ -394,7 +392,7 @@ static DWORD WINAPI proc_PlaySound(LPVOID arg)
/* make it so that 3 buffers per second are needed */ /* make it so that 3 buffers per second are needed */
bufsize = (((lpWaveFormat->nAvgBytesPerSec / 3) - 1) / lpWaveFormat->nBlockAlign + 1) * bufsize = (((lpWaveFormat->nAvgBytesPerSec / 3) - 1) / lpWaveFormat->nBlockAlign + 1) *
lpWaveFormat->nBlockAlign; lpWaveFormat->nBlockAlign;
waveHdr = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(WAVEHDR) + 2 * bufsize); waveHdr = malloc(2 * sizeof(WAVEHDR) + 2 * bufsize);
if (!waveHdr) if (!waveHdr)
goto errCleanUp; goto errCleanUp;
waveHdr[0].lpData = (char*)waveHdr + 2 * sizeof(WAVEHDR); waveHdr[0].lpData = (char*)waveHdr + 2 * sizeof(WAVEHDR);
...@@ -448,7 +446,7 @@ static DWORD WINAPI proc_PlaySound(LPVOID arg) ...@@ -448,7 +446,7 @@ static DWORD WINAPI proc_PlaySound(LPVOID arg)
errCleanUp: errCleanUp:
TRACE("Done playing=%s => %s!\n", debugstr_w(wps->pszSound), bRet ? "ok" : "ko"); TRACE("Done playing=%s => %s!\n", debugstr_w(wps->pszSound), bRet ? "ok" : "ko");
HeapFree(GetProcessHeap(), 0, lpWaveFormat); free(lpWaveFormat);
if (hWave) if (hWave)
{ {
EnterCriticalSection(&WINMM_cs); EnterCriticalSection(&WINMM_cs);
...@@ -459,7 +457,7 @@ errCleanUp: ...@@ -459,7 +457,7 @@ errCleanUp:
Sleep(100); Sleep(100);
} }
CloseHandle(s.hEvent); CloseHandle(s.hEvent);
HeapFree(GetProcessHeap(), 0, waveHdr); free(waveHdr);
if (hmmio) mmioClose(hmmio, 0); if (hmmio) mmioClose(hmmio, 0);
PlaySound_Free(wps); PlaySound_Free(wps);
......
...@@ -349,14 +349,14 @@ UINT WINAPI midiOutGetErrorTextA(UINT uError, LPSTR lpText, UINT uSize) ...@@ -349,14 +349,14 @@ UINT WINAPI midiOutGetErrorTextA(UINT uError, LPSTR lpText, UINT uSize)
else if (uSize == 0) ret = MMSYSERR_NOERROR; else if (uSize == 0) ret = MMSYSERR_NOERROR;
else else
{ {
LPWSTR xstr = HeapAlloc(GetProcessHeap(), 0, uSize * sizeof(WCHAR)); WCHAR *xstr = malloc(uSize * sizeof(WCHAR));
if (!xstr) ret = MMSYSERR_NOMEM; if (!xstr) ret = MMSYSERR_NOMEM;
else else
{ {
ret = midiOutGetErrorTextW(uError, xstr, uSize); ret = midiOutGetErrorTextW(uError, xstr, uSize);
if (ret == MMSYSERR_NOERROR) if (ret == MMSYSERR_NOERROR)
WideCharToMultiByte(CP_ACP, 0, xstr, -1, lpText, uSize, NULL, NULL); WideCharToMultiByte(CP_ACP, 0, xstr, -1, lpText, uSize, NULL, NULL);
HeapFree(GetProcessHeap(), 0, xstr); free(xstr);
} }
} }
return ret; return ret;
...@@ -957,7 +957,7 @@ static WINE_MIDIStream *wine_midi_stream_allocate(void) ...@@ -957,7 +957,7 @@ static WINE_MIDIStream *wine_midi_stream_allocate(void)
stream_id++; stream_id++;
if (stream_id < 0xFFFFFFFF && if (stream_id < 0xFFFFFFFF &&
(stream = HeapAlloc(GetProcessHeap(), 0, sizeof(WINE_MIDIStream)))) (stream = malloc(sizeof(WINE_MIDIStream))))
{ {
stream->dwStreamID = stream_id; stream->dwStreamID = stream_id;
wine_rb_put(&wine_midi_streams, &stream_id, &stream->entry); wine_rb_put(&wine_midi_streams, &stream_id, &stream->entry);
...@@ -972,7 +972,7 @@ static void wine_midi_stream_free(WINE_MIDIStream *stream) ...@@ -972,7 +972,7 @@ static void wine_midi_stream_free(WINE_MIDIStream *stream)
EnterCriticalSection(&WINMM_cs); EnterCriticalSection(&WINMM_cs);
wine_rb_remove(&wine_midi_streams, &stream->entry); wine_rb_remove(&wine_midi_streams, &stream->entry);
HeapFree(GetProcessHeap(), 0, stream); free(stream);
LeaveCriticalSection(&WINMM_cs); LeaveCriticalSection(&WINMM_cs);
} }
...@@ -1392,7 +1392,7 @@ MMRESULT WINAPI midiStreamOpen(HMIDISTRM* lphMidiStrm, LPUINT lpuDeviceID, ...@@ -1392,7 +1392,7 @@ MMRESULT WINAPI midiStreamOpen(HMIDISTRM* lphMidiStrm, LPUINT lpuDeviceID,
mosm.wDeviceID = *lpuDeviceID; mosm.wDeviceID = *lpuDeviceID;
lpwm = MIDI_OutAlloc(&hMidiOut, &dwCallback, &dwInstance, &fdwOpen, 1, &mosm); lpwm = MIDI_OutAlloc(&hMidiOut, &dwCallback, &dwInstance, &fdwOpen, 1, &mosm);
if (!lpwm) { if (!lpwm) {
HeapFree(GetProcessHeap(), 0, lpMidiStrm); free(lpMidiStrm);
return MMSYSERR_NOMEM; return MMSYSERR_NOMEM;
} }
lpMidiStrm->hDevice = hMidiOut; lpMidiStrm->hDevice = hMidiOut;
...@@ -1404,7 +1404,7 @@ MMRESULT WINAPI midiStreamOpen(HMIDISTRM* lphMidiStrm, LPUINT lpuDeviceID, ...@@ -1404,7 +1404,7 @@ MMRESULT WINAPI midiStreamOpen(HMIDISTRM* lphMidiStrm, LPUINT lpuDeviceID,
ret = MMDRV_Open(&lpwm->mld, MODM_OPEN, (DWORD_PTR)&lpwm->mod, CALLBACK_NULL); ret = MMDRV_Open(&lpwm->mld, MODM_OPEN, (DWORD_PTR)&lpwm->mod, CALLBACK_NULL);
if (ret != MMSYSERR_NOERROR) { if (ret != MMSYSERR_NOERROR) {
MMDRV_Free(hMidiOut, &lpwm->mld); MMDRV_Free(hMidiOut, &lpwm->mld);
HeapFree(GetProcessHeap(), 0, lpMidiStrm); free(lpMidiStrm);
return ret; return ret;
} }
...@@ -1682,7 +1682,7 @@ static DWORD WINAPI mmTaskRun(void* pmt) ...@@ -1682,7 +1682,7 @@ static DWORD WINAPI mmTaskRun(void* pmt)
struct mm_starter mms; struct mm_starter mms;
memcpy(&mms, pmt, sizeof(struct mm_starter)); memcpy(&mms, pmt, sizeof(struct mm_starter));
HeapFree(GetProcessHeap(), 0, pmt); free(pmt);
mms.cb(mms.client); mms.cb(mms.client);
if (mms.event) SetEvent(mms.event); if (mms.event) SetEvent(mms.event);
return 0; return 0;
...@@ -1697,7 +1697,7 @@ UINT WINAPI mmTaskCreate(LPTASKCALLBACK cb, HANDLE* ph, DWORD_PTR client) ...@@ -1697,7 +1697,7 @@ UINT WINAPI mmTaskCreate(LPTASKCALLBACK cb, HANDLE* ph, DWORD_PTR client)
HANDLE hEvent = 0; HANDLE hEvent = 0;
struct mm_starter *mms; struct mm_starter *mms;
mms = HeapAlloc(GetProcessHeap(), 0, sizeof(struct mm_starter)); mms = malloc(sizeof(struct mm_starter));
if (mms == NULL) return TASKERR_OUTOFMEMORY; if (mms == NULL) return TASKERR_OUTOFMEMORY;
mms->cb = cb; mms->cb = cb;
...@@ -1707,7 +1707,7 @@ UINT WINAPI mmTaskCreate(LPTASKCALLBACK cb, HANDLE* ph, DWORD_PTR client) ...@@ -1707,7 +1707,7 @@ UINT WINAPI mmTaskCreate(LPTASKCALLBACK cb, HANDLE* ph, DWORD_PTR client)
hThread = CreateThread(0, 0, mmTaskRun, mms, 0, NULL); hThread = CreateThread(0, 0, mmTaskRun, mms, 0, NULL);
if (!hThread) { if (!hThread) {
HeapFree(GetProcessHeap(), 0, mms); free(mms);
if (hEvent) CloseHandle(hEvent); if (hEvent) CloseHandle(hEvent);
return TASKERR_OUTOFMEMORY; return TASKERR_OUTOFMEMORY;
} }
......
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