Commit 90a5dc72 authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

mciwave: Use CRT allocation functions.

parent 7dc45bd8
...@@ -89,7 +89,7 @@ static DWORD CALLBACK MCI_SCAStarter(LPVOID arg) ...@@ -89,7 +89,7 @@ static DWORD CALLBACK MCI_SCAStarter(LPVOID arg)
ret = sca->cmd(sca->wDevID, sca->dwParam1 | MCI_WAIT, sca->dwParam2, sca->evt); ret = sca->cmd(sca->wDevID, sca->dwParam1 | MCI_WAIT, sca->dwParam2, sca->evt);
TRACE("In thread after async command (%08x,%08Ix,%08Ix)\n", TRACE("In thread after async command (%08x,%08Ix,%08Ix)\n",
sca->wDevID, sca->dwParam1, sca->dwParam2); sca->wDevID, sca->dwParam1, sca->dwParam2);
HeapFree(GetProcessHeap(), 0, sca); free(sca);
return ret; return ret;
} }
...@@ -100,7 +100,7 @@ static DWORD MCI_SendCommandAsync(UINT wDevID, async_cmd cmd, DWORD_PTR dwParam1 ...@@ -100,7 +100,7 @@ static DWORD MCI_SendCommandAsync(UINT wDevID, async_cmd cmd, DWORD_PTR dwParam1
DWORD_PTR dwParam2, UINT size) DWORD_PTR dwParam2, UINT size)
{ {
HANDLE handles[2]; HANDLE handles[2];
struct SCA* sca = HeapAlloc(GetProcessHeap(), 0, sizeof(struct SCA) + size); struct SCA* sca = malloc(sizeof(struct SCA) + size);
if (sca == 0) if (sca == 0)
return MCIERR_OUT_OF_MEMORY; return MCIERR_OUT_OF_MEMORY;
...@@ -182,7 +182,7 @@ static LRESULT WAVE_drvClose(MCIDEVICEID dwDevID) ...@@ -182,7 +182,7 @@ static LRESULT WAVE_drvClose(MCIDEVICEID dwDevID)
WINE_MCIWAVE* wmw = (WINE_MCIWAVE*)mciGetDriverData(dwDevID); WINE_MCIWAVE* wmw = (WINE_MCIWAVE*)mciGetDriverData(dwDevID);
if (wmw) { if (wmw) {
HeapFree(GetProcessHeap(), 0, wmw); free(wmw);
mciSetDriverData(dwDevID, 0); mciSetDriverData(dwDevID, 0);
return 1; return 1;
} }
...@@ -287,12 +287,12 @@ static DWORD WAVE_mciReadFmt(WINE_MCIWAVE* wmw, const MMCKINFO* pckMainRIFF) ...@@ -287,12 +287,12 @@ static DWORD WAVE_mciReadFmt(WINE_MCIWAVE* wmw, const MMCKINFO* pckMainRIFF)
TRACE("Chunk Found ckid=%.4s fccType=%.4s cksize=%08lX\n", TRACE("Chunk Found ckid=%.4s fccType=%.4s cksize=%08lX\n",
(LPSTR)&mmckInfo.ckid, (LPSTR)&mmckInfo.fccType, mmckInfo.cksize); (LPSTR)&mmckInfo.ckid, (LPSTR)&mmckInfo.fccType, mmckInfo.cksize);
pwfx = HeapAlloc(GetProcessHeap(), 0, mmckInfo.cksize); pwfx = malloc(mmckInfo.cksize);
if (!pwfx) return MCIERR_OUT_OF_MEMORY; if (!pwfx) return MCIERR_OUT_OF_MEMORY;
r = mmioRead(wmw->hFile, (HPSTR)pwfx, mmckInfo.cksize); r = mmioRead(wmw->hFile, (HPSTR)pwfx, mmckInfo.cksize);
if (r < 0 || r < sizeof(PCMWAVEFORMAT)) { if (r < 0 || r < sizeof(PCMWAVEFORMAT)) {
HeapFree(GetProcessHeap(), 0, pwfx); free(pwfx);
return MCIERR_INVALID_FILE; return MCIERR_INVALID_FILE;
} }
TRACE("wFormatTag=%04X !\n", pwfx->wFormatTag); TRACE("wFormatTag=%04X !\n", pwfx->wFormatTag);
...@@ -305,7 +305,7 @@ static DWORD WAVE_mciReadFmt(WINE_MCIWAVE* wmw, const MMCKINFO* pckMainRIFF) ...@@ -305,7 +305,7 @@ static DWORD WAVE_mciReadFmt(WINE_MCIWAVE* wmw, const MMCKINFO* pckMainRIFF)
TRACE("cbSize=%u !\n", pwfx->cbSize); TRACE("cbSize=%u !\n", pwfx->cbSize);
if ((pwfx->wFormatTag != WAVE_FORMAT_PCM) if ((pwfx->wFormatTag != WAVE_FORMAT_PCM)
&& (r < sizeof(WAVEFORMATEX) || (r < sizeof(WAVEFORMATEX) + pwfx->cbSize))) { && (r < sizeof(WAVEFORMATEX) || (r < sizeof(WAVEFORMATEX) + pwfx->cbSize))) {
HeapFree(GetProcessHeap(), 0, pwfx); free(pwfx);
return MCIERR_INVALID_FILE; return MCIERR_INVALID_FILE;
} }
wmw->lpWaveFormat = pwfx; wmw->lpWaveFormat = pwfx;
...@@ -437,7 +437,7 @@ static DWORD create_tmp_file(HMMIO* hFile, LPWSTR* pszTmpFileName) ...@@ -437,7 +437,7 @@ static DWORD create_tmp_file(HMMIO* hFile, LPWSTR* pszTmpFileName)
MAX_PATH * sizeof(WCHAR)); MAX_PATH * sizeof(WCHAR));
if (!GetTempFileNameW(szTmpPath, szPrefix, 0, *pszTmpFileName)) { if (!GetTempFileNameW(szTmpPath, szPrefix, 0, *pszTmpFileName)) {
WARN("can't retrieve temp file name!\n"); WARN("can't retrieve temp file name!\n");
HeapFree(GetProcessHeap(), 0, *pszTmpFileName); free(*pszTmpFileName);
return MCIERR_FILE_NOT_FOUND; return MCIERR_FILE_NOT_FOUND;
} }
...@@ -451,7 +451,7 @@ static DWORD create_tmp_file(HMMIO* hFile, LPWSTR* pszTmpFileName) ...@@ -451,7 +451,7 @@ static DWORD create_tmp_file(HMMIO* hFile, LPWSTR* pszTmpFileName)
if (*hFile == 0) { if (*hFile == 0) {
WARN("can't create file=%s!\n", debugstr_w(*pszTmpFileName)); WARN("can't create file=%s!\n", debugstr_w(*pszTmpFileName));
/* temporary file could not be created. clean filename. */ /* temporary file could not be created. clean filename. */
HeapFree(GetProcessHeap(), 0, *pszTmpFileName); free(*pszTmpFileName);
dwRet = MCIERR_FILE_NOT_FOUND; dwRet = MCIERR_FILE_NOT_FOUND;
} }
} }
...@@ -463,10 +463,9 @@ static LRESULT WAVE_mciOpenFile(WINE_MCIWAVE* wmw, LPCWSTR filename) ...@@ -463,10 +463,9 @@ static LRESULT WAVE_mciOpenFile(WINE_MCIWAVE* wmw, LPCWSTR filename)
LRESULT dwRet = MMSYSERR_NOERROR; LRESULT dwRet = MMSYSERR_NOERROR;
LPWSTR fn; LPWSTR fn;
fn = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(filename) + 1) * sizeof(WCHAR)); fn = wcsdup(filename);
if (!fn) return MCIERR_OUT_OF_MEMORY; if (!fn) return MCIERR_OUT_OF_MEMORY;
lstrcpyW(fn, filename); free(wmw->lpFileName);
HeapFree(GetProcessHeap(), 0, wmw->lpFileName);
wmw->lpFileName = fn; wmw->lpFileName = fn;
if (filename[0]) { if (filename[0]) {
...@@ -569,7 +568,7 @@ static LRESULT WAVE_mciOpen(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_WAVE_OPEN_P ...@@ -569,7 +568,7 @@ static LRESULT WAVE_mciOpen(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_WAVE_OPEN_P
if (wmw->hFile != 0) if (wmw->hFile != 0)
mmioClose(wmw->hFile, 0); mmioClose(wmw->hFile, 0);
wmw->hFile = 0; wmw->hFile = 0;
HeapFree(GetProcessHeap(), 0, wmw->lpFileName); free(wmw->lpFileName);
wmw->lpFileName = NULL; wmw->lpFileName = NULL;
} }
return dwRet; return dwRet;
...@@ -681,9 +680,9 @@ static DWORD WAVE_mciClose(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_GENERIC_PARM ...@@ -681,9 +680,9 @@ static DWORD WAVE_mciClose(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_GENERIC_PARM
} }
if (wmw->lpWaveFormat != &wmw->wfxRef) if (wmw->lpWaveFormat != &wmw->wfxRef)
HeapFree(GetProcessHeap(), 0, wmw->lpWaveFormat); free(wmw->lpWaveFormat);
wmw->lpWaveFormat = &wmw->wfxRef; wmw->lpWaveFormat = &wmw->wfxRef;
HeapFree(GetProcessHeap(), 0, wmw->lpFileName); free(wmw->lpFileName);
wmw->lpFileName = NULL; wmw->lpFileName = NULL;
if ((dwFlags & MCI_NOTIFY) && lpParms) { if ((dwFlags & MCI_NOTIFY) && lpParms) {
...@@ -854,7 +853,7 @@ static DWORD WAVE_mciPlay(MCIDEVICEID wDevID, DWORD_PTR dwFlags, DWORD_PTR pmt, ...@@ -854,7 +853,7 @@ static DWORD WAVE_mciPlay(MCIDEVICEID wDevID, DWORD_PTR dwFlags, DWORD_PTR pmt,
/* make it so that 3 buffers per second are needed */ /* make it so that 3 buffers per second are needed */
bufsize = WAVE_ALIGN_ON_BLOCK(wmw, wmw->lpWaveFormat->nAvgBytesPerSec / 3); bufsize = WAVE_ALIGN_ON_BLOCK(wmw, wmw->lpWaveFormat->nAvgBytesPerSec / 3);
waveHdr = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(WAVEHDR) + 2 * bufsize); waveHdr = malloc(2 * sizeof(WAVEHDR) + 2 * bufsize);
waveHdr[0].lpData = (char*)waveHdr + 2 * sizeof(WAVEHDR); waveHdr[0].lpData = (char*)waveHdr + 2 * sizeof(WAVEHDR);
waveHdr[1].lpData = (char*)waveHdr + 2 * sizeof(WAVEHDR) + bufsize; waveHdr[1].lpData = (char*)waveHdr + 2 * sizeof(WAVEHDR) + bufsize;
waveHdr[0].dwUser = waveHdr[1].dwUser = 0L; waveHdr[0].dwUser = waveHdr[1].dwUser = 0L;
...@@ -917,7 +916,7 @@ cleanUp: ...@@ -917,7 +916,7 @@ cleanUp:
if (dwFlags & MCI_NOTIFY) if (dwFlags & MCI_NOTIFY)
oldcb = InterlockedExchangePointer(&wmw->hCallback, NULL); oldcb = InterlockedExchangePointer(&wmw->hCallback, NULL);
HeapFree(GetProcessHeap(), 0, waveHdr); free(waveHdr);
if (wmw->hWave) { if (wmw->hWave) {
waveOutClose(wmw->hWave); waveOutClose(wmw->hWave);
...@@ -1038,7 +1037,7 @@ static DWORD WAVE_mciRecord(MCIDEVICEID wDevID, DWORD_PTR dwFlags, DWORD_PTR pmt ...@@ -1038,7 +1037,7 @@ static DWORD WAVE_mciRecord(MCIDEVICEID wDevID, DWORD_PTR dwFlags, DWORD_PTR pmt
* we don't modify the wave part of an existing file (ie. we always erase an * we don't modify the wave part of an existing file (ie. we always erase an
* existing content, we don't overwrite) * existing content, we don't overwrite)
*/ */
HeapFree(GetProcessHeap(), 0, wmw->lpFileName); free(wmw->lpFileName);
dwRet = create_tmp_file(&wmw->hFile, (WCHAR**)&wmw->lpFileName); dwRet = create_tmp_file(&wmw->hFile, (WCHAR**)&wmw->lpFileName);
if (dwRet != 0) return dwRet; if (dwRet != 0) return dwRet;
...@@ -1092,7 +1091,7 @@ static DWORD WAVE_mciRecord(MCIDEVICEID wDevID, DWORD_PTR dwFlags, DWORD_PTR pmt ...@@ -1092,7 +1091,7 @@ static DWORD WAVE_mciRecord(MCIDEVICEID wDevID, DWORD_PTR dwFlags, DWORD_PTR pmt
/* make it so that 3 buffers per second are needed */ /* make it so that 3 buffers per second are needed */
bufsize = WAVE_ALIGN_ON_BLOCK(wmw, wmw->lpWaveFormat->nAvgBytesPerSec / 3); bufsize = WAVE_ALIGN_ON_BLOCK(wmw, wmw->lpWaveFormat->nAvgBytesPerSec / 3);
waveHdr = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(WAVEHDR) + 2 * bufsize); waveHdr = malloc(2 * sizeof(WAVEHDR) + 2 * bufsize);
waveHdr[0].lpData = (char*)waveHdr + 2 * sizeof(WAVEHDR); waveHdr[0].lpData = (char*)waveHdr + 2 * sizeof(WAVEHDR);
waveHdr[1].lpData = (char*)waveHdr + 2 * sizeof(WAVEHDR) + bufsize; waveHdr[1].lpData = (char*)waveHdr + 2 * sizeof(WAVEHDR) + bufsize;
waveHdr[0].dwUser = waveHdr[1].dwUser = 0L; waveHdr[0].dwUser = waveHdr[1].dwUser = 0L;
...@@ -1143,7 +1142,7 @@ cleanUp: ...@@ -1143,7 +1142,7 @@ cleanUp:
if (dwFlags & MCI_NOTIFY) if (dwFlags & MCI_NOTIFY)
oldcb = InterlockedExchangePointer(&wmw->hCallback, NULL); oldcb = InterlockedExchangePointer(&wmw->hCallback, NULL);
HeapFree(GetProcessHeap(), 0, waveHdr); free(waveHdr);
if (wmw->hWave) { if (wmw->hWave) {
waveInClose(wmw->hWave); waveInClose(wmw->hWave);
......
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