From 4fa92f65e7ee498d687cacdb4ed06fb4c53dc53d Mon Sep 17 00:00:00 2001 From: Mike McCormack Date: Sat, 11 Mar 2006 14:42:14 +0900 Subject: [PATCH] avifil32: Use HeapAlloc instead of GlobalAlloc/LocalAlloc. --- dlls/avifil32/acmstream.c | 48 ++++++++++++++------------------------- 1 file changed, 17 insertions(+), 31 deletions(-) diff --git a/dlls/avifil32/acmstream.c b/dlls/avifil32/acmstream.c index 6ffe4161368..96d49b0d7ad 100644 --- a/dlls/avifil32/acmstream.c +++ b/dlls/avifil32/acmstream.c @@ -115,7 +115,7 @@ HRESULT AVIFILE_CreateACMStream(REFIID riid, LPVOID *ppv) *ppv = NULL; - pstream = (IAVIStreamImpl*)LocalAlloc(LPTR, sizeof(IAVIStreamImpl)); + pstream = HeapAlloc(GetProcessHeap(), 0, sizeof(IAVIStreamImpl)); if (pstream == NULL) return AVIERR_MEMORY; @@ -123,7 +123,7 @@ HRESULT AVIFILE_CreateACMStream(REFIID riid, LPVOID *ppv) hr = IAVIStream_QueryInterface((IAVIStream*)pstream, riid, ppv); if (FAILED(hr)) - LocalFree((HLOCAL)pstream); + HeapFree(GetProcessHeap(), 0, pstream); return hr; } @@ -176,24 +176,20 @@ static ULONG WINAPI ACMStream_fnRelease(IAVIStream* iface) This->has = NULL; } if (This->acmStreamHdr.pbSrc != NULL) { - GlobalUnlock(GlobalHandle(This->acmStreamHdr.pbSrc)); - GlobalFree(GlobalHandle(This->acmStreamHdr.pbSrc)); + HeapFree(GetProcessHeap(), 0, This->acmStreamHdr.pbSrc); This->acmStreamHdr.pbSrc = NULL; } if (This->acmStreamHdr.pbDst != NULL) { - GlobalUnlock(GlobalHandle(This->acmStreamHdr.pbDst)); - GlobalFree(GlobalHandle(This->acmStreamHdr.pbDst)); + HeapFree(GetProcessHeap(), 0, This->acmStreamHdr.pbDst); This->acmStreamHdr.pbDst = NULL; } if (This->lpInFormat != NULL) { - GlobalUnlock(GlobalHandle(This->lpInFormat)); - GlobalFree(GlobalHandle(This->lpInFormat)); + HeapFree(GetProcessHeap(), 0, This->lpInFormat); This->lpInFormat = NULL; This->cbInFormat = 0; } if (This->lpOutFormat != NULL) { - GlobalUnlock(GlobalHandle(This->lpOutFormat)); - GlobalFree(GlobalHandle(This->lpOutFormat)); + HeapFree(GetProcessHeap(), 0, This->lpOutFormat); This->lpOutFormat = NULL; This->cbOutFormat = 0; } @@ -201,7 +197,7 @@ static ULONG WINAPI ACMStream_fnRelease(IAVIStream* iface) IAVIStream_Release(This->pStream); This->pStream = NULL; } - LocalFree((HLOCAL)This); + HeapFree(GetProcessHeap(), 0, This); return 0; } @@ -253,7 +249,7 @@ static HRESULT WINAPI ACMStream_fnCreate(IAVIStream *iface, LPARAM lParam1, else This->cbOutFormat = sizeof(PCMWAVEFORMAT); - This->lpOutFormat = GlobalLock(GlobalAlloc(GHND, This->cbOutFormat)); + This->lpOutFormat = HeapAlloc(GetProcessHeap(), 0, This->cbOutFormat); if (This->lpOutFormat == NULL) return AVIERR_MEMORY; @@ -386,7 +382,7 @@ static HRESULT WINAPI ACMStream_fnSetFormat(IAVIStream *iface, LONG pos, if ((This->sInfo.dwCaps & AVIFILECAPS_CANWRITE) == 0) return AVIERR_READONLY; - This->lpInFormat = GlobalLock(GlobalAlloc(GMEM_MOVEABLE, formatsize)); + This->lpInFormat = HeapAlloc(GetProcessHeap(), 0, formatsize); if (This->lpInFormat == NULL) return AVIERR_MEMORY; This->cbInFormat = formatsize; @@ -466,8 +462,7 @@ static HRESULT WINAPI ACMStream_fnRead(IAVIStream *iface, LONG start, /* Need to free destination buffer used for writing? */ if (This->acmStreamHdr.pbDst != NULL) { - GlobalUnlock(GlobalHandle(This->acmStreamHdr.pbDst)); - GlobalFree(GlobalHandle(This->acmStreamHdr.pbDst)); + HeapFree(GetProcessHeap(), 0, This->acmStreamHdr.pbDst); This->acmStreamHdr.pbDst = NULL; This->acmStreamHdr.dwDstUser = 0; } @@ -476,13 +471,9 @@ static HRESULT WINAPI ACMStream_fnRead(IAVIStream *iface, LONG start, if (This->acmStreamHdr.pbSrc == NULL || This->acmStreamHdr.dwSrcUser < size) { if (This->acmStreamHdr.pbSrc == NULL) - This->acmStreamHdr.pbSrc = GlobalLock(GlobalAlloc(GMEM_MOVEABLE, size)); + This->acmStreamHdr.pbSrc = HeapAlloc(GetProcessHeap(), 0, size); else - { - GlobalUnlock(GlobalHandle(This->acmStreamHdr.pbSrc)); - This->acmStreamHdr.pbDst = GlobalReAlloc(GlobalHandle(This->acmStreamHdr.pbSrc), - size, GMEM_MOVEABLE); - } + This->acmStreamHdr.pbDst = HeapReAlloc(GetProcessHeap(), 0, This->acmStreamHdr.pbSrc, size); if (This->acmStreamHdr.pbSrc == NULL) return AVIERR_MEMORY; This->acmStreamHdr.dwSrcUser = size; @@ -574,8 +565,7 @@ static HRESULT WINAPI ACMStream_fnWrite(IAVIStream *iface, LONG start, /* Need to free source buffer used for reading? */ if (This->acmStreamHdr.pbSrc != NULL) { - GlobalUnlock(GlobalHandle(This->acmStreamHdr.pbSrc)); - GlobalFree(GlobalHandle(This->acmStreamHdr.pbSrc)); + HeapFree(GetProcessHeap(), 0, This->acmStreamHdr.pbSrc); This->acmStreamHdr.pbSrc = NULL; This->acmStreamHdr.dwSrcUser = 0; } @@ -584,13 +574,9 @@ static HRESULT WINAPI ACMStream_fnWrite(IAVIStream *iface, LONG start, if (This->acmStreamHdr.pbDst == NULL || This->acmStreamHdr.dwDstUser < size) { if (This->acmStreamHdr.pbDst == NULL) - This->acmStreamHdr.pbDst = GlobalLock(GlobalAlloc(GMEM_MOVEABLE, size)); + This->acmStreamHdr.pbDst = HeapAlloc(GetProcessHeap(), 0, size); else - { - GlobalUnlock(GlobalHandle(This->acmStreamHdr.pbDst)); - This->acmStreamHdr.pbDst = GlobalReAlloc(GlobalHandle(This->acmStreamHdr.pbDst), - size, GMEM_MOVEABLE); - } + This->acmStreamHdr.pbDst = HeapReAlloc(GetProcessHeap(), 0, This->acmStreamHdr.pbDst, size); if (This->acmStreamHdr.pbDst == NULL) return AVIERR_MEMORY; This->acmStreamHdr.dwDstUser = size; @@ -714,7 +700,7 @@ static HRESULT AVIFILE_OpenCompressor(IAVIStreamImpl *This) hr = AVIStreamFormatSize(This->pStream, This->sInfo.dwStart, &This->cbInFormat); if (FAILED(hr)) return hr; - This->lpInFormat = GlobalLock(GlobalAlloc(GMEM_MOVEABLE, This->cbInFormat)); + This->lpInFormat = HeapAlloc(GetProcessHeap(), 0, This->cbInFormat); if (This->lpInFormat == NULL) return AVIERR_MEMORY; @@ -726,7 +712,7 @@ static HRESULT AVIFILE_OpenCompressor(IAVIStreamImpl *This) if (This->lpOutFormat == NULL) { /* we must decode to default format */ This->cbOutFormat = sizeof(PCMWAVEFORMAT); - This->lpOutFormat = GlobalLock(GlobalAlloc(GHND, This->cbOutFormat)); + This->lpOutFormat = HeapAlloc(GetProcessHeap(), 0, This->cbOutFormat); if (This->lpOutFormat == NULL) return AVIERR_MEMORY;