Jörg Höhle : winmm: Replace one HeapAlloc with stack allocation.

Alexandre Julliard julliard at winehq.org
Fri Aug 5 10:20:49 CDT 2011


Module: wine
Branch: master
Commit: 710d2004274deecba33b85c6bb4651006f1c54c1
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=710d2004274deecba33b85c6bb4651006f1c54c1

Author: Jörg Höhle <hoehle at users.sourceforge.net>
Date:   Wed Jul 27 23:44:09 2011 +0200

winmm: Replace one HeapAlloc with stack allocation.

---

 dlls/winmm/waveform.c |   12 ++----------
 1 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/dlls/winmm/waveform.c b/dlls/winmm/waveform.c
index 918364b..d1c685e 100644
--- a/dlls/winmm/waveform.c
+++ b/dlls/winmm/waveform.c
@@ -820,7 +820,7 @@ static MMRESULT WINMM_MapDevice(WINMM_OpenInfo *info, BOOL is_out)
 static LRESULT WINMM_OpenDevice(WINMM_Device *device, WINMM_MMDevice *mmdevice,
         WINMM_OpenInfo *info)
 {
-    WAVEFORMATEX *closer_fmt = NULL, *passed_fmt;
+    WAVEFORMATEX *closer_fmt = NULL, fmt, *passed_fmt;
     LRESULT ret = MMSYSERR_ERROR;
     HRESULT hr;
 
@@ -843,7 +843,7 @@ static LRESULT WINMM_OpenDevice(WINMM_Device *device, WINMM_MMDevice *mmdevice,
     if(info->format->wFormatTag == WAVE_FORMAT_PCM){
         /* we aren't guaranteed that the struct in lpFormat is a full
          * WAVEFORMATEX struct, which IAC::IsFormatSupported requires */
-        passed_fmt = HeapAlloc(GetProcessHeap(), 0, sizeof(WAVEFORMATEX));
+        passed_fmt = &fmt;
         memcpy(passed_fmt, info->format, sizeof(PCMWAVEFORMAT));
         passed_fmt->cbSize = 0;
     }else
@@ -854,20 +854,14 @@ static LRESULT WINMM_OpenDevice(WINMM_Device *device, WINMM_MMDevice *mmdevice,
     if(closer_fmt)
         CoTaskMemFree(closer_fmt);
     if(FAILED(hr) && hr != AUDCLNT_E_UNSUPPORTED_FORMAT){
-        if(info->format->wFormatTag == WAVE_FORMAT_PCM)
-            HeapFree(GetProcessHeap(), 0, passed_fmt);
         ERR("IsFormatSupported failed: %08x\n", hr);
         goto error;
     }
     if(hr == S_FALSE || hr == AUDCLNT_E_UNSUPPORTED_FORMAT){
-        if(info->format->wFormatTag == WAVE_FORMAT_PCM)
-            HeapFree(GetProcessHeap(), 0, passed_fmt);
         ret = WAVERR_BADFORMAT;
         goto error;
     }
     if(info->flags & WAVE_FORMAT_QUERY){
-        if(info->format->wFormatTag == WAVE_FORMAT_PCM)
-            HeapFree(GetProcessHeap(), 0, passed_fmt);
         ret = MMSYSERR_NOERROR;
         goto error;
     }
@@ -876,8 +870,6 @@ static LRESULT WINMM_OpenDevice(WINMM_Device *device, WINMM_MMDevice *mmdevice,
     hr = IAudioClient_Initialize(device->client, AUDCLNT_SHAREMODE_SHARED,
             AUDCLNT_STREAMFLAGS_EVENTCALLBACK | AUDCLNT_STREAMFLAGS_NOPERSIST,
             10 * 100000, 50000, passed_fmt, &device->parent->session);
-    if(info->format->wFormatTag == WAVE_FORMAT_PCM)
-        HeapFree(GetProcessHeap(), 0, passed_fmt);
     if(FAILED(hr)){
         ERR("Initialize failed: %08x\n", hr);
         goto error;




More information about the wine-cvs mailing list