From: Alex Henrie alexhenrie24@gmail.com
--- dlls/avifil32/acmstream.c | 36 +++++------ dlls/avifil32/api.c | 68 ++++++++++----------- dlls/avifil32/avifile.c | 121 ++++++++++++++----------------------- dlls/avifil32/editstream.c | 24 ++++---- dlls/avifil32/extrachunk.c | 12 +--- dlls/avifil32/factory.c | 4 +- dlls/avifil32/getframe.c | 17 +++--- dlls/avifil32/icmstream.c | 32 +++++----- dlls/avifil32/tmpfile.c | 8 +-- dlls/avifil32/wavfile.c | 24 ++++---- 10 files changed, 151 insertions(+), 195 deletions(-)
diff --git a/dlls/avifil32/acmstream.c b/dlls/avifil32/acmstream.c index be8c7b7dc33..09db400513b 100644 --- a/dlls/avifil32/acmstream.c +++ b/dlls/avifil32/acmstream.c @@ -86,7 +86,7 @@ static HRESULT AVIFILE_OpenCompressor(IAVIStreamImpl *This) hr = AVIStreamFormatSize(This->pStream, This->sInfo.dwStart, &This->cbInFormat); if (FAILED(hr)) return hr; - This->lpInFormat = HeapAlloc(GetProcessHeap(), 0, This->cbInFormat); + This->lpInFormat = malloc(This->cbInFormat); if (This->lpInFormat == NULL) return AVIERR_MEMORY;
@@ -98,7 +98,7 @@ static HRESULT AVIFILE_OpenCompressor(IAVIStreamImpl *This) if (This->lpOutFormat == NULL) { /* we must decode to default format */ This->cbOutFormat = sizeof(WAVEFORMATEX); - This->lpOutFormat = HeapAlloc(GetProcessHeap(), 0, This->cbOutFormat); + This->lpOutFormat = malloc(This->cbOutFormat); if (This->lpOutFormat == NULL) return AVIERR_MEMORY;
@@ -181,17 +181,17 @@ static ULONG WINAPI ACMStream_fnRelease(IAVIStream* iface) acmStreamClose(This->has, 0); This->has = NULL; } - HeapFree(GetProcessHeap(), 0, This->acmStreamHdr.pbSrc); + free(This->acmStreamHdr.pbSrc); This->acmStreamHdr.pbSrc = NULL; - HeapFree(GetProcessHeap(), 0, This->acmStreamHdr.pbDst); + free(This->acmStreamHdr.pbDst); This->acmStreamHdr.pbDst = NULL; if (This->lpInFormat != NULL) { - HeapFree(GetProcessHeap(), 0, This->lpInFormat); + free(This->lpInFormat); This->lpInFormat = NULL; This->cbInFormat = 0; } if (This->lpOutFormat != NULL) { - HeapFree(GetProcessHeap(), 0, This->lpOutFormat); + free(This->lpOutFormat); This->lpOutFormat = NULL; This->cbOutFormat = 0; } @@ -199,7 +199,7 @@ static ULONG WINAPI ACMStream_fnRelease(IAVIStream* iface) IAVIStream_Release(This->pStream); This->pStream = NULL; } - HeapFree(GetProcessHeap(), 0, This); + free(This);
return 0; } @@ -251,7 +251,7 @@ static HRESULT WINAPI ACMStream_fnCreate(IAVIStream *iface, LPARAM lParam1, else This->cbOutFormat = sizeof(WAVEFORMATEX);
- This->lpOutFormat = HeapAlloc(GetProcessHeap(), 0, This->cbOutFormat); + This->lpOutFormat = malloc(This->cbOutFormat); if (This->lpOutFormat == NULL) return AVIERR_MEMORY;
@@ -384,7 +384,7 @@ static HRESULT WINAPI ACMStream_fnSetFormat(IAVIStream *iface, LONG pos, if ((This->sInfo.dwCaps & AVIFILECAPS_CANWRITE) == 0) return AVIERR_READONLY;
- This->lpInFormat = HeapAlloc(GetProcessHeap(), 0, formatsize); + This->lpInFormat = malloc(formatsize); if (This->lpInFormat == NULL) return AVIERR_MEMORY; This->cbInFormat = formatsize; @@ -464,7 +464,7 @@ static HRESULT WINAPI ACMStream_fnRead(IAVIStream *iface, LONG start,
/* Need to free destination buffer used for writing? */ if (This->acmStreamHdr.pbDst != NULL) { - HeapFree(GetProcessHeap(), 0, This->acmStreamHdr.pbDst); + free(This->acmStreamHdr.pbDst); This->acmStreamHdr.pbDst = NULL; This->acmStreamHdr.dwDstUser = 0; } @@ -472,10 +472,7 @@ static HRESULT WINAPI ACMStream_fnRead(IAVIStream *iface, LONG start, /* need bigger source buffer? */ if (This->acmStreamHdr.pbSrc == NULL || This->acmStreamHdr.dwSrcUser < size) { - if (This->acmStreamHdr.pbSrc == NULL) - This->acmStreamHdr.pbSrc = HeapAlloc(GetProcessHeap(), 0, size); - else - This->acmStreamHdr.pbSrc = HeapReAlloc(GetProcessHeap(), 0, This->acmStreamHdr.pbSrc, size); + This->acmStreamHdr.pbSrc = realloc(This->acmStreamHdr.pbSrc, size); if (This->acmStreamHdr.pbSrc == NULL) return AVIERR_MEMORY; This->acmStreamHdr.dwSrcUser = size; @@ -567,7 +564,7 @@ static HRESULT WINAPI ACMStream_fnWrite(IAVIStream *iface, LONG start,
/* Need to free source buffer used for reading? */ if (This->acmStreamHdr.pbSrc != NULL) { - HeapFree(GetProcessHeap(), 0, This->acmStreamHdr.pbSrc); + free(This->acmStreamHdr.pbSrc); This->acmStreamHdr.pbSrc = NULL; This->acmStreamHdr.dwSrcUser = 0; } @@ -575,10 +572,7 @@ static HRESULT WINAPI ACMStream_fnWrite(IAVIStream *iface, LONG start, /* Need bigger destination buffer? */ if (This->acmStreamHdr.pbDst == NULL || This->acmStreamHdr.dwDstUser < size) { - if (This->acmStreamHdr.pbDst == NULL) - This->acmStreamHdr.pbDst = HeapAlloc(GetProcessHeap(), 0, size); - else - This->acmStreamHdr.pbDst = HeapReAlloc(GetProcessHeap(), 0, This->acmStreamHdr.pbDst, size); + This->acmStreamHdr.pbDst = realloc(This->acmStreamHdr.pbDst, size); if (This->acmStreamHdr.pbDst == NULL) return AVIERR_MEMORY; This->acmStreamHdr.dwDstUser = size; @@ -710,7 +704,7 @@ HRESULT AVIFILE_CreateACMStream(REFIID riid, LPVOID *ppv)
*ppv = NULL;
- pstream = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IAVIStreamImpl)); + pstream = calloc(1, sizeof(IAVIStreamImpl)); if (pstream == NULL) return AVIERR_MEMORY;
@@ -718,7 +712,7 @@ HRESULT AVIFILE_CreateACMStream(REFIID riid, LPVOID *ppv)
hr = IAVIStream_QueryInterface(&pstream->IAVIStream_iface, riid, ppv); if (FAILED(hr)) - HeapFree(GetProcessHeap(), 0, pstream); + free(pstream);
return hr; } diff --git a/dlls/avifil32/api.c b/dlls/avifil32/api.c index 3054489bef2..fe0c163cf0a 100644 --- a/dlls/avifil32/api.c +++ b/dlls/avifil32/api.c @@ -208,7 +208,7 @@ HRESULT WINAPI AVIFileOpenA(PAVIFILE *ppfile, LPCSTR szFile, UINT uMode, if (len <= 0) return AVIERR_BADPARAM;
- wszFile = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); + wszFile = malloc(len * sizeof(WCHAR)); if (wszFile == NULL) return AVIERR_MEMORY;
@@ -216,7 +216,7 @@ HRESULT WINAPI AVIFileOpenA(PAVIFILE *ppfile, LPCSTR szFile, UINT uMode,
hr = AVIFileOpenW(ppfile, wszFile, uMode, lpHandler);
- HeapFree(GetProcessHeap(), 0, wszFile); + free(wszFile);
return hr; } @@ -974,7 +974,7 @@ HRESULT WINAPI AVIBuildFilterA(LPSTR szFilter, LONG cbFilter, BOOL fSaving) szFilter[0] = 0; szFilter[1] = 0;
- wszFilter = HeapAlloc(GetProcessHeap(), 0, cbFilter * sizeof(WCHAR)); + wszFilter = malloc(cbFilter * sizeof(WCHAR)); if (wszFilter == NULL) return AVIERR_MEMORY;
@@ -984,7 +984,7 @@ HRESULT WINAPI AVIBuildFilterA(LPSTR szFilter, LONG cbFilter, BOOL fSaving) szFilter, cbFilter, NULL, NULL); }
- HeapFree(GetProcessHeap(), 0, wszFilter); + free(wszFilter);
return hr; } @@ -1013,7 +1013,7 @@ HRESULT WINAPI AVIBuildFilterW(LPWSTR szFilter, LONG cbFilter, BOOL fSaving) if (cbFilter < 2) return AVIERR_BADSIZE;
- lp = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, MAX_FILTERS * sizeof(AVIFilter)); + lp = calloc(MAX_FILTERS, sizeof(AVIFilter)); if (lp == NULL) return AVIERR_MEMORY;
@@ -1027,7 +1027,7 @@ HRESULT WINAPI AVIBuildFilterW(LPWSTR szFilter, LONG cbFilter, BOOL fSaving) * collection of all possible extensions except "*.*". */ if (RegOpenKeyW(HKEY_CLASSES_ROOT, L"AVIFile\Extensions", &hKey) != ERROR_SUCCESS) { - HeapFree(GetProcessHeap(), 0, lp); + free(lp); return AVIERR_ERROR; } for (n = 0;RegEnumKeyW(hKey, n, szFileExt, ARRAY_SIZE(szFileExt)) == ERROR_SUCCESS;n++) { @@ -1077,7 +1077,7 @@ HRESULT WINAPI AVIBuildFilterW(LPWSTR szFilter, LONG cbFilter, BOOL fSaving)
/* 2. get descriptions for the CLSIDs and fill out szFilter */ if (RegOpenKeyW(HKEY_CLASSES_ROOT, L"CLSID", &hKey) != ERROR_SUCCESS) { - HeapFree(GetProcessHeap(), 0, lp); + free(lp); return AVIERR_ERROR; } for (n = 0; n <= count; n++) { @@ -1096,7 +1096,7 @@ HRESULT WINAPI AVIBuildFilterW(LPWSTR szFilter, LONG cbFilter, BOOL fSaving) if (cbFilter < size + lstrlenW(lp[n].szExtensions) + 2) { szFilter[0] = 0; szFilter[1] = 0; - HeapFree(GetProcessHeap(), 0, lp); + free(lp); RegCloseKey(hKey); return AVIERR_BUFFERTOOSMALL; } @@ -1111,7 +1111,7 @@ HRESULT WINAPI AVIBuildFilterW(LPWSTR szFilter, LONG cbFilter, BOOL fSaving) }
RegCloseKey(hKey); - HeapFree(GetProcessHeap(), 0, lp); + free(lp);
/* add "All files" "*.*" filter if enough space left */ size = LoadStringW(AVIFILE_hModule, IDS_ALLFILES, szAllFiles, @@ -1212,11 +1212,11 @@ static BOOL AVISaveOptionsFmtChoose(HWND hWnd)
acmMetrics(NULL, ACM_METRIC_MAX_SIZE_FORMAT, &size); if ((pOptions->cbFormat == 0 || pOptions->lpFormat == NULL) && size != 0) { - pOptions->lpFormat = HeapAlloc(GetProcessHeap(), 0, size); + pOptions->lpFormat = malloc(size); if (!pOptions->lpFormat) return FALSE; pOptions->cbFormat = size; } else if (pOptions->cbFormat < (DWORD)size) { - void *new_buffer = HeapReAlloc(GetProcessHeap(), 0, pOptions->lpFormat, size); + void *new_buffer = realloc(pOptions->lpFormat, size); if (!new_buffer) return FALSE; pOptions->lpFormat = new_buffer; pOptions->cbFormat = size; @@ -1229,7 +1229,7 @@ static BOOL AVISaveOptionsFmtChoose(HWND hWnd) sInfo.dwStart, &size); if (size < (LONG)sizeof(PCMWAVEFORMAT)) size = sizeof(PCMWAVEFORMAT); - afmtc.pwfxEnum = HeapAlloc(GetProcessHeap(), 0, size); + afmtc.pwfxEnum = malloc(size); if (afmtc.pwfxEnum != NULL) { AVIStreamReadFormat(SaveOpts.ppavis[SaveOpts.nCurrent], sInfo.dwStart, afmtc.pwfxEnum, &size); @@ -1240,7 +1240,7 @@ static BOOL AVISaveOptionsFmtChoose(HWND hWnd) if (ret == S_OK) pOptions->dwFlags |= AVICOMPRESSF_VALID;
- HeapFree(GetProcessHeap(), 0, afmtc.pwfxEnum); + free(afmtc.pwfxEnum); return ret == S_OK; } else { ERR(": unknown streamtype 0x%08lX\n", sInfo.fccType); @@ -1269,7 +1269,7 @@ static void AVISaveOptionsUpdate(HWND hWnd) szFormat[0] = 0;
/* read format to build format description string */ - lpFormat = HeapAlloc(GetProcessHeap(), 0, size); + lpFormat = malloc(size); if (lpFormat != NULL) { if (SUCCEEDED(AVIStreamReadFormat(SaveOpts.ppavis[SaveOpts.nCurrent],sInfo.dwStart,lpFormat, &size))) { if (sInfo.fccType == streamtypeVIDEO) { @@ -1317,7 +1317,7 @@ static void AVISaveOptionsUpdate(HWND hWnd) } } } - HeapFree(GetProcessHeap(), 0, lpFormat); + free(lpFormat); }
/* set text for format description */ @@ -1433,7 +1433,7 @@ BOOL WINAPI AVISaveOptions(HWND hWnd, UINT uFlags, INT nStreams,
/* save options in case the user presses cancel */ if (nStreams > 1) { - pSavedOptions = HeapAlloc(GetProcessHeap(), 0, nStreams * sizeof(AVICOMPRESSOPTIONS)); + pSavedOptions = malloc(nStreams * sizeof(AVICOMPRESSOPTIONS)); if (pSavedOptions == NULL) return FALSE;
@@ -1462,7 +1462,7 @@ BOOL WINAPI AVISaveOptions(HWND hWnd, UINT uFlags, INT nStreams, memcpy(ppOptions[n], pSavedOptions + n, sizeof(AVICOMPRESSOPTIONS)); } } - HeapFree(GetProcessHeap(), 0, pSavedOptions); + free(pSavedOptions); }
return ret; @@ -1483,12 +1483,12 @@ HRESULT WINAPI AVISaveOptionsFree(INT nStreams,LPAVICOMPRESSOPTIONS*ppOptions) ppOptions[nStreams]->dwFlags &= ~AVICOMPRESSF_VALID;
if (ppOptions[nStreams]->lpParms != NULL) { - HeapFree(GetProcessHeap(), 0, ppOptions[nStreams]->lpParms); + free(ppOptions[nStreams]->lpParms); ppOptions[nStreams]->lpParms = NULL; ppOptions[nStreams]->cbParms = 0; } if (ppOptions[nStreams]->lpFormat != NULL) { - HeapFree(GetProcessHeap(), 0, ppOptions[nStreams]->lpFormat); + free(ppOptions[nStreams]->lpFormat); ppOptions[nStreams]->lpFormat = NULL; ppOptions[nStreams]->cbFormat = 0; } @@ -1520,7 +1520,7 @@ HRESULT WINAPI AVISaveVA(LPCSTR szFile, CLSID *pclsidHandler, if (len <= 0) return AVIERR_BADPARAM;
- wszFile = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); + wszFile = malloc(len * sizeof(WCHAR)); if (wszFile == NULL) return AVIERR_MEMORY;
@@ -1529,7 +1529,7 @@ HRESULT WINAPI AVISaveVA(LPCSTR szFile, CLSID *pclsidHandler, hr = AVISaveVW(wszFile, pclsidHandler, lpfnCallback, nStream, ppavi, plpOptions);
- HeapFree(GetProcessHeap(), 0, wszFile); + free(wszFile);
return hr; } @@ -1671,7 +1671,7 @@ HRESULT WINAPI AVISaveVW(LPCWSTR szFile, CLSID *pclsidHandler,
/* allocate buffer for formats, data, etc. of an initial size of 64 kBytes*/ cbBuffer = 0x00010000; - lpBuffer = HeapAlloc(GetProcessHeap(), 0, cbBuffer); + lpBuffer = malloc(cbBuffer); if (lpBuffer == NULL) { hres = AVIERR_MEMORY; goto error; @@ -1814,7 +1814,7 @@ HRESULT WINAPI AVISaveVW(LPCWSTR szFile, CLSID *pclsidHandler, lFirstVideo - lStart[curStream], lpBuffer, cbBuffer, &lReadBytes, &lReadSamples); } while ((hres == AVIERR_BUFFERTOOSMALL) && - (lpBuffer = HeapReAlloc(GetProcessHeap(), 0, lpBuffer, cbBuffer *= 2)) != NULL); + (lpBuffer = realloc(lpBuffer, cbBuffer *= 2)) != NULL); if (lpBuffer == NULL) hres = AVIERR_MEMORY; if (FAILED(hres)) @@ -1883,7 +1883,7 @@ HRESULT WINAPI AVISaveVW(LPCWSTR szFile, CLSID *pclsidHandler, hres = AVIStreamRead(pInStreams[curStream],sInfo.dwStart,lSamples, lpBuffer,cbBuffer,&lReadBytes,&lReadSamples); } while ((hres == AVIERR_BUFFERTOOSMALL) && - (lpBuffer = HeapReAlloc(GetProcessHeap(), 0, lpBuffer, cbBuffer *= 2)) != NULL); + (lpBuffer = realloc(lpBuffer, cbBuffer *= 2)) != NULL); if (lpBuffer == NULL) hres = AVIERR_MEMORY; if (FAILED(hres)) @@ -1929,7 +1929,7 @@ HRESULT WINAPI AVISaveVW(LPCWSTR szFile, CLSID *pclsidHandler, hres = AVIStreamRead(pInStreams[curStream], sInfo.dwStart, 1, lpBuffer, cbBuffer,&lReadBytes,&lReadSamples); } while ((hres == AVIERR_BUFFERTOOSMALL) && - (lpBuffer = HeapReAlloc(GetProcessHeap(), 0, lpBuffer, cbBuffer *= 2)) != NULL); + (lpBuffer = realloc(lpBuffer, cbBuffer *= 2)) != NULL); if (lpBuffer == NULL) hres = AVIERR_MEMORY; if (FAILED(hres)) @@ -1958,7 +1958,7 @@ HRESULT WINAPI AVISaveVW(LPCWSTR szFile, CLSID *pclsidHandler, }
error: - HeapFree(GetProcessHeap(), 0, lpBuffer); + free(lpBuffer); if (pfile != NULL) { for (curStream = 0; curStream < nStreams; curStream++) { if (pOutStreams[curStream] != NULL) @@ -2244,8 +2244,8 @@ HRESULT WINAPIV AVISaveA(LPCSTR szFile, CLSID * pclsidHandler, AVISAVECALLBACK l
if (nStreams <= 0) return AVIERR_BADPARAM;
- streams = HeapAlloc(GetProcessHeap(), 0, nStreams * sizeof(*streams)); - options = HeapAlloc(GetProcessHeap(), 0, nStreams * sizeof(*options)); + streams = malloc(nStreams * sizeof(*streams)); + options = malloc(nStreams * sizeof(*options)); if (!streams || !options) { ret = AVIERR_MEMORY; @@ -2268,8 +2268,8 @@ HRESULT WINAPIV AVISaveA(LPCSTR szFile, CLSID * pclsidHandler, AVISAVECALLBACK l
ret = AVISaveVA(szFile, pclsidHandler, lpfnCallback, nStreams, streams, options); error: - HeapFree(GetProcessHeap(), 0, streams); - HeapFree(GetProcessHeap(), 0, options); + free(streams); + free(options); return ret; }
@@ -2287,8 +2287,8 @@ HRESULT WINAPIV AVISaveW(LPCWSTR szFile, CLSID * pclsidHandler, AVISAVECALLBACK
if (nStreams <= 0) return AVIERR_BADPARAM;
- streams = HeapAlloc(GetProcessHeap(), 0, nStreams * sizeof(*streams)); - options = HeapAlloc(GetProcessHeap(), 0, nStreams * sizeof(*options)); + streams = malloc(nStreams * sizeof(*streams)); + options = malloc(nStreams * sizeof(*options)); if (!streams || !options) { ret = AVIERR_MEMORY; @@ -2311,7 +2311,7 @@ HRESULT WINAPIV AVISaveW(LPCWSTR szFile, CLSID * pclsidHandler, AVISAVECALLBACK
ret = AVISaveVW(szFile, pclsidHandler, lpfnCallback, nStreams, streams, options); error: - HeapFree(GetProcessHeap(), 0, streams); - HeapFree(GetProcessHeap(), 0, options); + free(streams); + free(options); return ret; } diff --git a/dlls/avifil32/avifile.c b/dlls/avifil32/avifile.c index a663264ce28..97aba8ce699 100644 --- a/dlls/avifil32/avifile.c +++ b/dlls/avifil32/avifile.c @@ -214,24 +214,24 @@ static ULONG WINAPI IUnknown_fnRelease(IUnknown *iface) ERR(": someone has still %lu reference to stream %u (%p)!\n", This->ppStreams[i]->ref, i, This->ppStreams[i]); AVIFILE_DestructAVIStream(This->ppStreams[i]); - HeapFree(GetProcessHeap(), 0, This->ppStreams[i]); + free(This->ppStreams[i]); This->ppStreams[i] = NULL; } }
if (This->idxRecords != NULL) { - HeapFree(GetProcessHeap(), 0, This->idxRecords); + free(This->idxRecords); This->idxRecords = NULL; This->nIdxRecords = 0; }
if (This->fileextra.lp != NULL) { - HeapFree(GetProcessHeap(), 0, This->fileextra.lp); + free(This->fileextra.lp); This->fileextra.lp = NULL; This->fileextra.cb = 0; }
- HeapFree(GetProcessHeap(), 0, This->szFileName); + free(This->szFileName); This->szFileName = NULL;
if (This->hmmio != NULL) { @@ -239,7 +239,7 @@ static ULONG WINAPI IUnknown_fnRelease(IUnknown *iface) This->hmmio = NULL; }
- HeapFree(GetProcessHeap(), 0, This); + free(This); } return ref; } @@ -351,8 +351,7 @@ static HRESULT WINAPI IAVIFile_fnCreateStream(IAVIFile *iface, IAVIStream **avis
/* now it seems to be save to add the stream */ assert(This->ppStreams[n] == NULL); - This->ppStreams[n] = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, - sizeof(IAVIStreamImpl)); + This->ppStreams[n] = calloc(1, sizeof(IAVIStreamImpl)); if (This->ppStreams[n] == NULL) return AVIERR_MEMORY;
@@ -464,7 +463,7 @@ static HRESULT WINAPI IAVIFile_fnDeleteStream(IAVIFile *iface, DWORD fccType, LO if (nStream < This->fInfo.dwStreams && This->ppStreams[nStream] != NULL) { /* ... so delete it now */ - HeapFree(GetProcessHeap(), 0, This->ppStreams[nStream]); + free(This->ppStreams[nStream]); This->fInfo.dwStreams--; if (nStream < This->fInfo.dwStreams) memmove(&This->ppStreams[nStream], &This->ppStreams[nStream + 1], @@ -553,7 +552,7 @@ static HRESULT WINAPI IPersistFile_fnLoad(IPersistFile *iface, LPCOLESTR pszFile This->uMode = dwMode;
len = lstrlenW(pszFileName) + 1; - This->szFileName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); + This->szFileName = malloc(len * sizeof(WCHAR)); if (This->szFileName == NULL) return AVIERR_MEMORY; lstrcpyW(This->szFileName, pszFileName); @@ -565,14 +564,14 @@ static HRESULT WINAPI IPersistFile_fnLoad(IPersistFile *iface, LPCOLESTR pszFile LPSTR szFileName;
len = WideCharToMultiByte(CP_ACP, 0, This->szFileName, -1, NULL, 0, NULL, NULL); - szFileName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(CHAR)); + szFileName = malloc(len * sizeof(CHAR)); if (szFileName == NULL) return AVIERR_MEMORY;
WideCharToMultiByte(CP_ACP, 0, This->szFileName, -1, szFileName, len, NULL, NULL);
This->hmmio = mmioOpenA(szFileName, NULL, MMIO_ALLOCBUF | dwMode); - HeapFree(GetProcessHeap(), 0, szFileName); + free(szFileName); if (This->hmmio == NULL) return AVIERR_FILEOPEN; } @@ -648,7 +647,7 @@ HRESULT AVIFILE_CreateAVIFile(IUnknown *pUnkOuter, REFIID riid, void **ppv) HRESULT hr;
*ppv = NULL; - obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IAVIFileImpl)); + obj = calloc(1, sizeof(IAVIFileImpl)); if (!obj) return AVIERR_MEMORY;
@@ -907,7 +906,7 @@ static HRESULT WINAPI IAVIStream_fnSetFormat(IAVIStream *iface, LONG pos, void * if (This->paf->dwMoviChunkPos != 0) return AVIERR_ERROR; /* user has used API in wrong sequence! */
- This->lpFormat = HeapAlloc(GetProcessHeap(), 0, formatsize); + This->lpFormat = malloc(formatsize); if (This->lpFormat == NULL) return AVIERR_MEMORY; This->cbFormat = formatsize; @@ -958,7 +957,7 @@ static HRESULT WINAPI IAVIStream_fnSetFormat(IAVIStream *iface, LONG pos, void * /* simply say all colors have changed */ ck.ckid = MAKEAVICKID(cktypePALchange, This->nStream); ck.cksize = 2 * sizeof(WORD) + lpbiOld->biClrUsed * sizeof(PALETTEENTRY); - lppc = HeapAlloc(GetProcessHeap(), 0, ck.cksize); + lppc = malloc(ck.cksize); if (lppc == NULL) return AVIERR_MEMORY;
@@ -977,13 +976,13 @@ static HRESULT WINAPI IAVIStream_fnSetFormat(IAVIStream *iface, LONG pos, void * mmioWrite(This->paf->hmmio, (HPSTR)lppc, ck.cksize) != ck.cksize || mmioAscend(This->paf->hmmio, &ck, 0) != S_OK) { - HeapFree(GetProcessHeap(), 0, lppc); + free(lppc); return AVIERR_FILEWRITE; }
This->paf->dwNextFramePos += ck.cksize + 2 * sizeof(DWORD);
- HeapFree(GetProcessHeap(), 0, lppc); + free(lppc);
return AVIFILE_AddFrame(This, cktypePALchange, n, ck.dwDataOffset, 0); } @@ -1295,7 +1294,7 @@ static HRESULT WINAPI IAVIStream_fnWriteData(IAVIStream *iface, DWORD fcc, void return AVIERR_UNSUPPORTED; }
- This->lpHandlerData = HeapAlloc(GetProcessHeap(), 0, size); + This->lpHandlerData = malloc(size); if (This->lpHandlerData == NULL) return AVIERR_MEMORY; This->cbHandlerData = size; @@ -1355,18 +1354,9 @@ static HRESULT AVIFILE_AddFrame(IAVIStreamImpl *This, DWORD ckid, DWORD size, DW
if (This->idxFmtChanges == NULL || This->nIdxFmtChanges <= This->sInfo.dwFormatChangeCount) { DWORD new_count = This->nIdxFmtChanges + 16; - void *new_buffer; - - if (This->idxFmtChanges == NULL) { - This->idxFmtChanges = - HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, new_count * sizeof(AVIINDEXENTRY)); - if (!This->idxFmtChanges) return AVIERR_MEMORY; - } else { - new_buffer = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->idxFmtChanges, - new_count * sizeof(AVIINDEXENTRY)); - if (!new_buffer) return AVIERR_MEMORY; - This->idxFmtChanges = new_buffer; - } + void *new_buffer = _recalloc(This->idxFmtChanges, new_count, sizeof(AVIINDEXENTRY)); + if (!new_buffer) return AVIERR_MEMORY; + This->idxFmtChanges = new_buffer; This->nIdxFmtChanges = new_count; }
@@ -1397,11 +1387,7 @@ static HRESULT AVIFILE_AddFrame(IAVIStreamImpl *This, DWORD ckid, DWORD size, DW /* get memory for index */ if (This->idxFrames == NULL || This->lLastFrame + 1 >= This->nIdxFrames) { This->nIdxFrames += 512; - if (This->idxFrames == NULL) - This->idxFrames = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->nIdxFrames * sizeof(AVIINDEXENTRY)); - else - This->idxFrames = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->idxFrames, - This->nIdxFrames * sizeof(AVIINDEXENTRY)); + This->idxFrames = _recalloc(This->idxFrames, This->nIdxFrames, sizeof(AVIINDEXENTRY)); if (This->idxFrames == NULL) return AVIERR_MEMORY; } @@ -1427,15 +1413,12 @@ static HRESULT AVIFILE_AddRecord(IAVIFileImpl *This) if (This->idxRecords == NULL || This->cbIdxRecords / sizeof(AVIINDEXENTRY) <= This->nIdxRecords) { DWORD new_count = This->cbIdxRecords + 1024 * sizeof(AVIINDEXENTRY); void *mem; - if (!This->idxRecords) - mem = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, new_count); - else - mem = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->idxRecords, new_count); + mem = _recalloc(This->idxRecords, 1, new_count); if (mem) { This->cbIdxRecords = new_count; This->idxRecords = mem; } else { - HeapFree(GetProcessHeap(), 0, This->idxRecords); + free(This->idxRecords); This->idxRecords = NULL; return AVIERR_MEMORY; } @@ -1510,15 +1493,13 @@ static void AVIFILE_ConstructAVIStream(IAVIFileImpl *paf, DWORD nr, const AVISTR
if (asi->dwLength > 0) { /* pre-allocate mem for frame-index structure */ - pstream->idxFrames = - HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, asi->dwLength * sizeof(AVIINDEXENTRY)); + pstream->idxFrames = calloc(asi->dwLength, sizeof(AVIINDEXENTRY)); if (pstream->idxFrames != NULL) pstream->nIdxFrames = asi->dwLength; } if (asi->dwFormatChangeCount > 0) { /* pre-allocate mem for formatchange-index structure */ - pstream->idxFmtChanges = - HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, asi->dwFormatChangeCount * sizeof(AVIINDEXENTRY)); + pstream->idxFmtChanges = calloc(asi->dwFormatChangeCount, sizeof(AVIINDEXENTRY)); if (pstream->idxFmtChanges != NULL) pstream->nIdxFmtChanges = asi->dwFormatChangeCount; } @@ -1544,29 +1525,29 @@ static void AVIFILE_DestructAVIStream(IAVIStreamImpl *This) This->lLastFrame = -1; This->paf = NULL; if (This->idxFrames != NULL) { - HeapFree(GetProcessHeap(), 0, This->idxFrames); + free(This->idxFrames); This->idxFrames = NULL; This->nIdxFrames = 0; } - HeapFree(GetProcessHeap(), 0, This->idxFmtChanges); + free(This->idxFmtChanges); This->idxFmtChanges = NULL; if (This->lpBuffer != NULL) { - HeapFree(GetProcessHeap(), 0, This->lpBuffer); + free(This->lpBuffer); This->lpBuffer = NULL; This->cbBuffer = 0; } if (This->lpHandlerData != NULL) { - HeapFree(GetProcessHeap(), 0, This->lpHandlerData); + free(This->lpHandlerData); This->lpHandlerData = NULL; This->cbHandlerData = 0; } if (This->extra.lp != NULL) { - HeapFree(GetProcessHeap(), 0, This->extra.lp); + free(This->extra.lp); This->extra.lp = NULL; This->extra.cb = 0; } if (This->lpFormat != NULL) { - HeapFree(GetProcessHeap(), 0, This->lpFormat); + free(This->lpFormat); This->lpFormat = NULL; This->cbFormat = 0; } @@ -1655,8 +1636,7 @@ static HRESULT AVIFILE_LoadFile(IAVIFileImpl *This) /* nested chunk must be of type "LIST","strl" -- when not normally JUNK */ if (ckLIST2.ckid == FOURCC_LIST && ckLIST2.fccType == listtypeSTREAMHEADER) { - pStream = This->ppStreams[nStream] = - HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IAVIStreamImpl)); + pStream = This->ppStreams[nStream] = calloc(1, sizeof(IAVIStreamImpl)); if (pStream == NULL) return AVIERR_MEMORY; AVIFILE_ConstructAVIStream(This, nStream, NULL); @@ -1667,7 +1647,7 @@ static HRESULT AVIFILE_LoadFile(IAVIFileImpl *This) case ckidSTREAMHANDLERDATA: if (pStream->lpHandlerData != NULL) return AVIERR_BADFORMAT; - pStream->lpHandlerData = HeapAlloc(GetProcessHeap(), 0, ck.cksize); + pStream->lpHandlerData = malloc(ck.cksize); if (pStream->lpHandlerData == NULL) return AVIERR_MEMORY; pStream->cbHandlerData = ck.cksize; @@ -1681,7 +1661,7 @@ static HRESULT AVIFILE_LoadFile(IAVIFileImpl *This) if (ck.cksize == 0) break;
- pStream->lpFormat = HeapAlloc(GetProcessHeap(), 0, ck.cksize); + pStream->lpFormat = malloc(ck.cksize); if (pStream->lpFormat == NULL) return AVIERR_MEMORY; pStream->cbFormat = ck.cksize; @@ -1769,20 +1749,20 @@ static HRESULT AVIFILE_LoadFile(IAVIFileImpl *This) break; case ckidSTREAMNAME: { /* streamname will be saved as ASCII string */ - LPSTR str = HeapAlloc(GetProcessHeap(), 0, ck.cksize); + char *str = malloc(ck.cksize); if (str == NULL) return AVIERR_MEMORY;
if (mmioRead(This->hmmio, str, ck.cksize) != ck.cksize) { - HeapFree(GetProcessHeap(), 0, str); + free(str); return AVIERR_FILEREAD; }
MultiByteToWideChar(CP_ACP, 0, str, -1, pStream->sInfo.szName, ARRAY_SIZE(pStream->sInfo.szName));
- HeapFree(GetProcessHeap(), 0, str); + free(str); } break; case ckidAVIPADDING: @@ -1902,7 +1882,7 @@ static HRESULT AVIFILE_LoadIndex(const IAVIFileImpl *This, DWORD size, DWORD off HRESULT hr = AVIERR_OK; BOOL bAbsolute = TRUE;
- lp = HeapAlloc(GetProcessHeap(), 0, IDX_PER_BLOCK * sizeof(AVIINDEXENTRY)); + lp = malloc(IDX_PER_BLOCK * sizeof(AVIINDEXENTRY)); if (lp == NULL) return AVIERR_MEMORY;
@@ -1913,7 +1893,7 @@ static HRESULT AVIFILE_LoadIndex(const IAVIFileImpl *This, DWORD size, DWORD off pStream->lLastFrame = -1;
if (pStream->idxFrames != NULL) { - HeapFree(GetProcessHeap(), 0, pStream->idxFrames); + free(pStream->idxFrames); pStream->idxFrames = NULL; pStream->nIdxFrames = 0; } @@ -1928,11 +1908,10 @@ static HRESULT AVIFILE_LoadIndex(const IAVIFileImpl *This, DWORD size, DWORD off } else pStream->nIdxFrames = pStream->sInfo.dwLength;
- pStream->idxFrames = - HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, pStream->nIdxFrames * sizeof(AVIINDEXENTRY)); + pStream->idxFrames = calloc(pStream->nIdxFrames, sizeof(AVIINDEXENTRY)); if (pStream->idxFrames == NULL && pStream->nIdxFrames > 0) { pStream->nIdxFrames = 0; - HeapFree(GetProcessHeap(), 0, lp); + free(lp); return AVIERR_MEMORY; } } @@ -1954,7 +1933,7 @@ static HRESULT AVIFILE_LoadIndex(const IAVIFileImpl *This, DWORD size, DWORD off pos, &bAbsolute); }
- HeapFree(GetProcessHeap(), 0, lp); + free(lp);
/* checking ... */ for (n = 0; n < This->fInfo.dwStreams; n++) { @@ -2025,15 +2004,9 @@ static HRESULT AVIFILE_ReadBlock(IAVIStreamImpl *This, DWORD pos, /* check that buffer is big enough -- don't trust dwSuggestedBufferSize */ if (This->lpBuffer == NULL || This->cbBuffer < size) { DWORD maxSize = max(size, This->sInfo.dwSuggestedBufferSize); - - if (This->lpBuffer == NULL) { - This->lpBuffer = HeapAlloc(GetProcessHeap(), 0, maxSize); - if (!This->lpBuffer) return AVIERR_MEMORY; - } else { - void *new_buffer = HeapReAlloc(GetProcessHeap(), 0, This->lpBuffer, maxSize); - if (!new_buffer) return AVIERR_MEMORY; - This->lpBuffer = new_buffer; - } + void *new_buffer = realloc(This->lpBuffer, maxSize); + if (!new_buffer) return AVIERR_MEMORY; + This->lpBuffer = new_buffer; This->cbBuffer = maxSize; }
@@ -2241,18 +2214,18 @@ static HRESULT AVIFILE_SaveFile(IAVIFileImpl *This) return AVIERR_FILEWRITE;
/* the streamname must be saved in ASCII not Unicode */ - str = HeapAlloc(GetProcessHeap(), 0, ck.cksize); + str = malloc(ck.cksize); if (str == NULL) return AVIERR_MEMORY; WideCharToMultiByte(CP_ACP, 0, pStream->sInfo.szName, -1, str, ck.cksize, NULL, NULL);
if (mmioWrite(This->hmmio, str, ck.cksize) != ck.cksize) { - HeapFree(GetProcessHeap(), 0, str); + free(str); return AVIERR_FILEWRITE; }
- HeapFree(GetProcessHeap(), 0, str); + free(str); if (mmioAscend(This->hmmio, &ck, 0) != S_OK) return AVIERR_FILEWRITE; } diff --git a/dlls/avifil32/editstream.c b/dlls/avifil32/editstream.c index 9dc09e4db8c..07136b2054a 100644 --- a/dlls/avifil32/editstream.c +++ b/dlls/avifil32/editstream.c @@ -209,19 +209,19 @@ static BOOL AVIFILE_FormatsEqual(PAVISTREAM avi1, PAVISTREAM avi2) return FALSE;
/* sizes match, now get formats and compare them */ - fmt1 = HeapAlloc(GetProcessHeap(), 0, size1); + fmt1 = malloc(size1); if (fmt1 == NULL) return FALSE; if (SUCCEEDED(AVIStreamReadFormat(avi1, start1, fmt1, &size1))) { - fmt2 = HeapAlloc(GetProcessHeap(), 0, size1); + fmt2 = malloc(size1); if (fmt2 != NULL) { if (SUCCEEDED(AVIStreamReadFormat(avi2, start2, fmt2, &size1))) status = (memcmp(fmt1, fmt2, size1) == 0); } }
- HeapFree(GetProcessHeap(), 0, fmt2); - HeapFree(GetProcessHeap(), 0, fmt1); + free(fmt2); + free(fmt1);
return status; } @@ -278,10 +278,10 @@ static ULONG WINAPI IAVIEditStream_fnRelease(IAVIEditStream*iface) if (This->pStreams[i].pStream != NULL) IAVIStream_Release(This->pStreams[i].pStream); } - HeapFree(GetProcessHeap(), 0, This->pStreams); + free(This->pStreams); }
- HeapFree(GetProcessHeap(), 0, This); + free(This); } return ref; } @@ -343,8 +343,7 @@ static HRESULT WINAPI IAVIEditStream_fnCut(IAVIEditStream*iface,LONG*plStart, } else { /* splitting */ if (This->nStreams + 1 >= This->nTableSize) { - This->pStreams = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->pStreams, - (This->nTableSize + 32) * sizeof(EditStreamTable)); + This->pStreams = _recalloc(This->pStreams, This->nTableSize + 32, sizeof(EditStreamTable)); if (This->pStreams == NULL) return AVIERR_MEMORY; This->nTableSize += 32; @@ -530,7 +529,7 @@ static HRESULT WINAPI IAVIEditStream_fnPaste(IAVIEditStream*iface,LONG*plStart, if (This->nStreams + nStreams + 1 > This->nTableSize) { n = This->nStreams + nStreams + 33;
- This->pStreams = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->pStreams, n * sizeof(EditStreamTable)); + This->pStreams = _recalloc(This->pStreams, n, sizeof(EditStreamTable)); if (This->pStreams == NULL) return AVIERR_MEMORY; This->nTableSize = n; @@ -619,8 +618,7 @@ static HRESULT WINAPI IAVIEditStream_fnClone(IAVIEditStream*iface, if (pEdit == NULL) return AVIERR_MEMORY; if (This->nStreams > pEdit->nTableSize) { - pEdit->pStreams = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, pEdit->pStreams, - This->nStreams * sizeof(EditStreamTable)); + pEdit->pStreams = _recalloc(pEdit->pStreams, This->nStreams, sizeof(EditStreamTable)); if (pEdit->pStreams == NULL) return AVIERR_MEMORY; pEdit->nTableSize = This->nStreams; @@ -702,7 +700,7 @@ static HRESULT WINAPI IEditAVIStream_fnCreate(IAVIStream*iface, return AVIERR_ERROR;
if (This->pStreams == NULL) { - This->pStreams = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 256 * sizeof(EditStreamTable)); + This->pStreams = calloc(256, sizeof(EditStreamTable)); if (This->pStreams == NULL) return AVIERR_MEMORY; This->nTableSize = 256; @@ -1010,7 +1008,7 @@ static IAVIEditStreamImpl *AVIFILE_CreateEditStream(IAVIStream *pstream) { IAVIEditStreamImpl *pedit = NULL;
- pedit = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IAVIEditStreamImpl)); + pedit = calloc(1, sizeof(IAVIEditStreamImpl)); if (pedit == NULL) return NULL;
diff --git a/dlls/avifil32/extrachunk.c b/dlls/avifil32/extrachunk.c index e142d1bb1de..256c23fc712 100644 --- a/dlls/avifil32/extrachunk.c +++ b/dlls/avifil32/extrachunk.c @@ -76,11 +76,7 @@ HRESULT WriteExtraChunk(LPEXTRACHUNKS extra,FOURCC ckid,LPCVOID lpData, LONG siz assert(lpData != NULL); assert(size > 0);
- if (extra->lp) - lp = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, extra->lp, extra->cb + size + 2 * sizeof(DWORD)); - else - lp = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size + 2 * sizeof(DWORD)); - + lp = _recalloc(extra->lp, 1, extra->cb + size + 2 * sizeof(DWORD)); if (lp == NULL) return AVIERR_MEMORY;
@@ -112,11 +108,7 @@ HRESULT ReadChunkIntoExtra(LPEXTRACHUNKS extra,HMMIO hmmio,const MMCKINFO *lpck) cb = lpck->cksize + 2 * sizeof(DWORD); cb += (cb & 1);
- if (extra->lp != NULL) - lp = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, extra->lp, extra->cb + cb); - else - lp = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cb); - + lp = _recalloc(extra->lp, 1, extra->cb + cb); if (lp == NULL) return AVIERR_MEMORY;
diff --git a/dlls/avifil32/factory.c b/dlls/avifil32/factory.c index 486043f059f..4848f34f87e 100644 --- a/dlls/avifil32/factory.c +++ b/dlls/avifil32/factory.c @@ -82,7 +82,7 @@ static ULONG WINAPI IClassFactory_fnRelease(IClassFactory *iface) TRACE("(%p) ref = %lu\n", This, ref);
if(!ref) - HeapFree(GetProcessHeap(), 0, This); + free(This);
return ref; } @@ -140,7 +140,7 @@ static HRESULT AVIFILE_CreateClassFactory(const CLSID *clsid, const IID *riid, v
*ppv = NULL;
- cf = HeapAlloc(GetProcessHeap(), 0, sizeof(*cf)); + cf = malloc(sizeof(*cf)); if (!cf) return E_OUTOFMEMORY;
diff --git a/dlls/avifil32/getframe.c b/dlls/avifil32/getframe.c index 7eb8b2fce93..c6df7339256 100644 --- a/dlls/avifil32/getframe.c +++ b/dlls/avifil32/getframe.c @@ -77,10 +77,10 @@ static inline IGetFrameImpl *impl_from_IGetFrame(IGetFrame *iface) static void AVIFILE_CloseCompressor(IGetFrameImpl *This) { if (This->lpInFormat != This->lpOutFormat) { - HeapFree(GetProcessHeap(), 0, This->lpOutFormat); + free(This->lpOutFormat); This->lpOutFormat = NULL; } - HeapFree(GetProcessHeap(), 0, This->lpInFormat); + free(This->lpInFormat); This->lpInFormat = NULL; if (This->hic != NULL) { if (This->bResize) @@ -133,7 +133,7 @@ static ULONG WINAPI IGetFrame_fnRelease(IGetFrame *iface) This->pStream = NULL; }
- HeapFree(GetProcessHeap(), 0, iface); + free(iface); }
return ref; @@ -222,7 +222,7 @@ static LPVOID WINAPI IGetFrame_fnGetFrame(IGetFrame *iface, LONG lPos) if (This->cbInBuffer >= readBytes) break; This->cbInBuffer = This->cbInFormat + readBytes; - This->lpInFormat = HeapReAlloc(GetProcessHeap(), 0, This->lpInFormat, This->cbInBuffer); + This->lpInFormat = realloc(This->lpInFormat, This->cbInBuffer); if (This->lpInFormat == NULL) return NULL; /* out of memory */ This->lpInBuffer = (BYTE*)This->lpInFormat + This->cbInFormat; @@ -322,7 +322,7 @@ static HRESULT WINAPI IGetFrame_fnSetFormat(IGetFrame *iface, IAVIStream_ReadFormat(This->pStream, sInfo.dwStart, NULL, &This->cbInFormat);
- This->lpInFormat = HeapAlloc(GetProcessHeap(), 0, This->cbInFormat + This->cbInBuffer); + This->lpInFormat = malloc(This->cbInFormat + This->cbInBuffer); if (This->lpInFormat == NULL) { AVIFILE_CloseCompressor(This); return AVIERR_MEMORY; @@ -361,8 +361,7 @@ static HRESULT WINAPI IGetFrame_fnSetFormat(IGetFrame *iface,
/* need memory for output format? */ if (This->lpOutFormat == NULL) { - This->lpOutFormat = - HeapAlloc(GetProcessHeap(), 0, sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD)); + This->lpOutFormat = malloc(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD)); if (This->lpOutFormat == NULL) { AVIFILE_CloseCompressor(This); return AVIERR_MEMORY; @@ -430,7 +429,7 @@ static HRESULT WINAPI IGetFrame_fnSetFormat(IGetFrame *iface, DWORD size = This->lpOutFormat->biClrUsed * sizeof(RGBQUAD);
size += This->lpOutFormat->biSize + This->lpOutFormat->biSizeImage; - This->lpOutFormat = HeapReAlloc(GetProcessHeap(), 0, This->lpOutFormat, size); + This->lpOutFormat = realloc(This->lpOutFormat, size); if (This->lpOutFormat == NULL) { AVIFILE_CloseCompressor(This); return AVIERR_MEMORY; @@ -492,7 +491,7 @@ PGETFRAME AVIFILE_CreateGetFrame(PAVISTREAM pStream) if (pStream == NULL) return NULL;
- pg = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IGetFrameImpl)); + pg = calloc(1, sizeof(IGetFrameImpl)); if (pg != NULL) { pg->IGetFrame_iface.lpVtbl = &igetframeVtbl; pg->ref = 1; diff --git a/dlls/avifil32/icmstream.c b/dlls/avifil32/icmstream.c index b234a58323b..ca7f35eebe7 100644 --- a/dlls/avifil32/icmstream.c +++ b/dlls/avifil32/icmstream.c @@ -140,7 +140,7 @@ static ULONG WINAPI ICMStream_fnRelease(IAVIStream* iface) if (This->hic != NULL) { if (This->lpbiPrev != NULL) { ICDecompressEnd(This->hic); - HeapFree(GetProcessHeap(), 0, This->lpbiPrev); + free(This->lpbiPrev); This->lpbiPrev = NULL; This->lpPrev = NULL; } @@ -148,22 +148,22 @@ static ULONG WINAPI ICMStream_fnRelease(IAVIStream* iface) This->hic = NULL; } if (This->lpbiCur != NULL) { - HeapFree(GetProcessHeap(), 0, This->lpbiCur); + free(This->lpbiCur); This->lpbiCur = NULL; This->lpCur = NULL; } if (This->lpbiOutput != NULL) { - HeapFree(GetProcessHeap(), 0, This->lpbiOutput); + free(This->lpbiOutput); This->lpbiOutput = NULL; This->cbOutput = 0; } if (This->lpbiInput != NULL) { - HeapFree(GetProcessHeap(), 0, This->lpbiInput); + free(This->lpbiInput); This->lpbiInput = NULL; This->cbInput = 0; }
- HeapFree(GetProcessHeap(), 0, This); + free(This);
return 0; } @@ -425,7 +425,7 @@ static HRESULT WINAPI ICMStream_fnSetFormat(IAVIStream *iface, LONG pos, assert(This->hic != NULL);
/* get memory for input format */ - This->lpbiInput = HeapAlloc(GetProcessHeap(), 0, formatsize); + This->lpbiInput = malloc(formatsize); if (This->lpbiInput == NULL) return AVIERR_MEMORY; This->cbInput = formatsize; @@ -435,7 +435,7 @@ static HRESULT WINAPI ICMStream_fnSetFormat(IAVIStream *iface, LONG pos, size = ICCompressGetFormatSize(This->hic, This->lpbiInput); if (size < sizeof(BITMAPINFOHEADER)) return AVIERR_COMPRESSOR; - This->lpbiOutput = HeapAlloc(GetProcessHeap(), 0, size); + This->lpbiOutput = malloc(size); if (This->lpbiOutput == NULL) return AVIERR_MEMORY; This->cbOutput = size; @@ -454,7 +454,7 @@ static HRESULT WINAPI ICMStream_fnSetFormat(IAVIStream *iface, LONG pos,
/* allocate memory for compressed frame */ size = ICCompressGetSize(This->hic, This->lpbiInput, This->lpbiOutput); - This->lpbiCur = HeapAlloc(GetProcessHeap(), 0, This->cbOutput + size); + This->lpbiCur = malloc(This->cbOutput + size); if (This->lpbiCur == NULL) return AVIERR_MEMORY; memcpy(This->lpbiCur, This->lpbiOutput, This->cbOutput); @@ -464,7 +464,7 @@ static HRESULT WINAPI ICMStream_fnSetFormat(IAVIStream *iface, LONG pos, if (This->lKeyFrameEvery != 1 && (This->dwICMFlags & VIDCF_FASTTEMPORALC) == 0) { size = ICDecompressGetFormatSize(This->hic, This->lpbiOutput); - This->lpbiPrev = HeapAlloc(GetProcessHeap(), 0, size); + This->lpbiPrev = malloc(size); if (This->lpbiPrev == NULL) return AVIERR_MEMORY; if (ICDecompressGetFormat(This->hic, This->lpbiOutput, This->lpbiPrev) < S_OK) @@ -477,7 +477,7 @@ static HRESULT WINAPI ICMStream_fnSetFormat(IAVIStream *iface, LONG pos,
/* get memory for format and picture */ size += This->lpbiPrev->biSizeImage; - This->lpbiPrev = HeapReAlloc(GetProcessHeap(), 0, This->lpbiPrev, size); + This->lpbiPrev = realloc(This->lpbiPrev, size); if (This->lpbiPrev == NULL) return AVIERR_MEMORY; This->lpPrev = DIBPTR(This->lpbiPrev); @@ -733,7 +733,7 @@ HRESULT AVIFILE_CreateICMStream(REFIID riid, LPVOID *ppv)
*ppv = NULL;
- pstream = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IAVIStreamImpl)); + pstream = calloc(1, sizeof(IAVIStreamImpl)); if (pstream == NULL) return AVIERR_MEMORY;
@@ -742,7 +742,7 @@ HRESULT AVIFILE_CreateICMStream(REFIID riid, LPVOID *ppv)
hr = IAVIStream_QueryInterface(&pstream->IAVIStream_iface, riid, ppv); if (FAILED(hr)) - HeapFree(GetProcessHeap(), 0, pstream); + free(pstream);
return hr; } @@ -900,7 +900,7 @@ static HRESULT AVIFILE_OpenGetFrame(IAVIStreamImpl *This) size = ICCompressGetFormatSize(This->hic, lpbi); if ((LONG)size < (LONG)sizeof(BITMAPINFOHEADER)) return AVIERR_COMPRESSOR; - This->lpbiOutput = HeapAlloc(GetProcessHeap(), 0, size); + This->lpbiOutput = malloc(size); if (This->lpbiOutput == NULL) return AVIERR_MEMORY; This->cbOutput = size; @@ -922,7 +922,7 @@ static HRESULT AVIFILE_OpenGetFrame(IAVIStreamImpl *This)
/* allocate memory for current frame */ size += This->sInfo.dwSuggestedBufferSize; - This->lpbiCur = HeapAlloc(GetProcessHeap(), 0, size); + This->lpbiCur = malloc(size); if (This->lpbiCur == NULL) return AVIERR_MEMORY; memcpy(This->lpbiCur, This->lpbiOutput, This->cbOutput); @@ -932,7 +932,7 @@ static HRESULT AVIFILE_OpenGetFrame(IAVIStreamImpl *This) if (This->lKeyFrameEvery != 1 && (This->dwICMFlags & VIDCF_FASTTEMPORALC) == 0) { size = ICDecompressGetFormatSize(This->hic, This->lpbiOutput); - This->lpbiPrev = HeapAlloc(GetProcessHeap(), 0, size); + This->lpbiPrev = malloc(size); if (This->lpbiPrev == NULL) return AVIERR_MEMORY; if (ICDecompressGetFormat(This->hic, This->lpbiOutput, This->lpbiPrev) < S_OK) @@ -945,7 +945,7 @@ static HRESULT AVIFILE_OpenGetFrame(IAVIStreamImpl *This)
/* get memory for format and picture */ size += This->lpbiPrev->biSizeImage; - This->lpbiPrev = HeapReAlloc(GetProcessHeap(), 0, This->lpbiPrev, size ); + This->lpbiPrev = realloc(This->lpbiPrev, size); if (This->lpbiPrev == NULL) return AVIERR_MEMORY; This->lpPrev = DIBPTR(This->lpbiPrev); diff --git a/dlls/avifil32/tmpfile.c b/dlls/avifil32/tmpfile.c index 4d81775b5bd..f5eaac35fb2 100644 --- a/dlls/avifil32/tmpfile.c +++ b/dlls/avifil32/tmpfile.c @@ -93,7 +93,7 @@ static ULONG WINAPI ITmpFile_fnRelease(IAVIFile *iface) } }
- HeapFree(GetProcessHeap(), 0, This); + free(This); }
return ref; @@ -222,7 +222,7 @@ PAVIFILE AVIFILE_CreateAVITempFile(int nStreams, const PAVISTREAM *ppStreams) ITmpFileImpl *tmpFile; int i;
- tmpFile = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ITmpFileImpl)); + tmpFile = calloc(1, sizeof(ITmpFileImpl)); if (tmpFile == NULL) return NULL;
@@ -231,9 +231,9 @@ PAVIFILE AVIFILE_CreateAVITempFile(int nStreams, const PAVISTREAM *ppStreams) memset(&tmpFile->fInfo, 0, sizeof(tmpFile->fInfo));
tmpFile->fInfo.dwStreams = nStreams; - tmpFile->ppStreams = HeapAlloc(GetProcessHeap(), 0, nStreams * sizeof(PAVISTREAM)); + tmpFile->ppStreams = malloc(nStreams * sizeof(PAVISTREAM)); if (tmpFile->ppStreams == NULL) { - HeapFree(GetProcessHeap(), 0, tmpFile); + free(tmpFile); return NULL; }
diff --git a/dlls/avifil32/wavfile.c b/dlls/avifil32/wavfile.c index 8eea55c2199..7f6fc736159 100644 --- a/dlls/avifil32/wavfile.c +++ b/dlls/avifil32/wavfile.c @@ -169,19 +169,19 @@ static ULONG WINAPI IUnknown_fnRelease(IUnknown *iface) if (This->fDirty) AVIFILE_SaveFile(This);
- HeapFree(GetProcessHeap(), 0, This->lpFormat); + free(This->lpFormat); This->lpFormat = NULL; This->cbFormat = 0; - HeapFree(GetProcessHeap(), 0, This->extra.lp); + free(This->extra.lp); This->extra.lp = NULL; This->extra.cb = 0; - HeapFree(GetProcessHeap(), 0, This->szFileName); + free(This->szFileName); This->szFileName = NULL; if (This->hmmio) { mmioClose(This->hmmio, 0); This->hmmio = NULL; } - HeapFree(GetProcessHeap(), 0, This); + free(This); }
return ref; @@ -388,7 +388,7 @@ static HRESULT WINAPI IAVIFile_fnDeleteStream(IAVIFile *iface, DWORD fccType, LO if ((This->uMode & MMIO_RWMODE) == 0) return AVIERR_READONLY;
- HeapFree(GetProcessHeap(), 0, This->lpFormat); + free(This->lpFormat); This->lpFormat = NULL; This->cbFormat = 0;
@@ -492,7 +492,7 @@ static HRESULT WINAPI IPersistFile_fnLoad(IPersistFile *iface, LPCOLESTR pszFile This->uMode = dwMode;
len = lstrlenW(pszFileName) + 1; - This->szFileName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); + This->szFileName = malloc(len * sizeof(WCHAR)); if (This->szFileName == NULL) return AVIERR_MEMORY; lstrcpyW(This->szFileName, pszFileName); @@ -504,7 +504,7 @@ static HRESULT WINAPI IPersistFile_fnLoad(IPersistFile *iface, LPCOLESTR pszFile LPSTR szFileName; len = WideCharToMultiByte(CP_ACP, 0, This->szFileName, -1, NULL, 0, NULL, NULL); - szFileName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(CHAR)); + szFileName = malloc(len * sizeof(CHAR)); if (szFileName == NULL) return AVIERR_MEMORY;
@@ -512,7 +512,7 @@ static HRESULT WINAPI IPersistFile_fnLoad(IPersistFile *iface, LPCOLESTR pszFile len, NULL, NULL);
This->hmmio = mmioOpenA(szFileName, NULL, MMIO_ALLOCBUF | dwMode); - HeapFree(GetProcessHeap(), 0, szFileName); + free(szFileName); if (This->hmmio == NULL) return AVIERR_FILEOPEN; } @@ -741,7 +741,7 @@ static HRESULT WINAPI IAVIStream_fnSetFormat(IAVIStream *iface, LONG pos, void * return AVIERR_READONLY;
/* get memory for format and copy it */ - This->lpFormat = HeapAlloc(GetProcessHeap(), 0, formatsize); + This->lpFormat = malloc(formatsize); if (This->lpFormat == NULL) return AVIERR_MEMORY;
@@ -982,7 +982,7 @@ HRESULT AVIFILE_CreateWAVFile(IUnknown *outer_unk, REFIID riid, void **ret_iface
*ret_iface = NULL;
- pfile = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pfile)); + pfile = calloc(1, sizeof(*pfile)); if (!pfile) return AVIERR_MEMORY;
@@ -1028,7 +1028,7 @@ static HRESULT AVIFILE_LoadFile(IAVIFileImpl *This) return AVIERR_FILEREAD;
/* get memory for format and read it */ - This->lpFormat = HeapAlloc(GetProcessHeap(), 0, ck.cksize); + This->lpFormat = malloc(ck.cksize); if (This->lpFormat == NULL) return AVIERR_FILEREAD; This->cbFormat = ck.cksize; @@ -1117,7 +1117,7 @@ static HRESULT AVIFILE_LoadSunFile(IAVIFileImpl *This) This->cbFormat = sizeof(WAVEFORMATEX); break; };
- This->lpFormat = HeapAlloc(GetProcessHeap(), 0, This->cbFormat); + This->lpFormat = malloc(This->cbFormat); if (This->lpFormat == NULL) return AVIERR_MEMORY;