Module: wine Branch: master Commit: 8316a77959722c9c3cc5fbf69cf9345e1a88979e URL: http://source.winehq.org/git/wine.git/?a=commit;h=8316a77959722c9c3cc5fbf69c...
Author: Jörg Höhle hoehle@users.sourceforge.net Date: Thu Jan 5 17:58:21 2012 +0100
mmdevapi: Avoid HeapRealloc when no data need be copied.
---
dlls/winealsa.drv/mmdevdrv.c | 18 ++++++------------ dlls/wineoss.drv/mmdevdrv.c | 17 ++++++----------- 2 files changed, 12 insertions(+), 23 deletions(-)
diff --git a/dlls/winealsa.drv/mmdevdrv.c b/dlls/winealsa.drv/mmdevdrv.c index 2557e6e..3168e8f 100644 --- a/dlls/winealsa.drv/mmdevdrv.c +++ b/dlls/winealsa.drv/mmdevdrv.c @@ -2029,12 +2029,9 @@ static HRESULT WINAPI AudioRenderClient_GetBuffer(IAudioRenderClient *iface, (This->lcl_offs_frames + This->held_frames) % This->bufsize_frames; if(write_pos + frames > This->bufsize_frames){ if(This->tmp_buffer_frames < frames){ - if(This->tmp_buffer) - This->tmp_buffer = HeapReAlloc(GetProcessHeap(), 0, - This->tmp_buffer, frames * This->fmt->nBlockAlign); - else - This->tmp_buffer = HeapAlloc(GetProcessHeap(), 0, - frames * This->fmt->nBlockAlign); + HeapFree(GetProcessHeap(), 0, This->tmp_buffer); + This->tmp_buffer = HeapAlloc(GetProcessHeap(), 0, + frames * This->fmt->nBlockAlign); if(!This->tmp_buffer){ LeaveCriticalSection(&This->lock); return E_OUTOFMEMORY; @@ -2184,12 +2181,9 @@ static HRESULT WINAPI AudioCaptureClient_GetBuffer(IAudioCaptureClient *iface, if(This->lcl_offs_frames + *frames > This->bufsize_frames){ UINT32 chunk_bytes, offs_bytes, frames_bytes; if(This->tmp_buffer_frames < *frames){ - if(This->tmp_buffer) - This->tmp_buffer = HeapReAlloc(GetProcessHeap(), 0, - This->tmp_buffer, *frames * This->fmt->nBlockAlign); - else - This->tmp_buffer = HeapAlloc(GetProcessHeap(), 0, - *frames * This->fmt->nBlockAlign); + HeapFree(GetProcessHeap(), 0, This->tmp_buffer); + This->tmp_buffer = HeapAlloc(GetProcessHeap(), 0, + *frames * This->fmt->nBlockAlign); if(!This->tmp_buffer){ LeaveCriticalSection(&This->lock); return E_OUTOFMEMORY; diff --git a/dlls/wineoss.drv/mmdevdrv.c b/dlls/wineoss.drv/mmdevdrv.c index dbbcd9f..e80385c 100644 --- a/dlls/wineoss.drv/mmdevdrv.c +++ b/dlls/wineoss.drv/mmdevdrv.c @@ -1738,12 +1738,9 @@ static HRESULT WINAPI AudioRenderClient_GetBuffer(IAudioRenderClient *iface, (This->lcl_offs_frames + This->held_frames) % This->bufsize_frames; if(write_pos + frames > This->bufsize_frames){ if(This->tmp_buffer_frames < frames){ - if(This->tmp_buffer) - This->tmp_buffer = HeapReAlloc(GetProcessHeap(), 0, - This->tmp_buffer, frames * This->fmt->nBlockAlign); - else - This->tmp_buffer = HeapAlloc(GetProcessHeap(), 0, - frames * This->fmt->nBlockAlign); + HeapFree(GetProcessHeap(), 0, This->tmp_buffer); + This->tmp_buffer = HeapAlloc(GetProcessHeap(), 0, + frames * This->fmt->nBlockAlign); if(!This->tmp_buffer){ LeaveCriticalSection(&This->lock); return E_OUTOFMEMORY; @@ -1922,11 +1919,9 @@ static HRESULT WINAPI AudioCaptureClient_GetBuffer(IAudioCaptureClient *iface, UINT32 chunk_bytes, offs_bytes, frames_bytes; if(This->tmp_buffer_frames < *frames){ if(This->tmp_buffer) - This->tmp_buffer = HeapReAlloc(GetProcessHeap(), 0, - This->tmp_buffer, *frames * This->fmt->nBlockAlign); - else - This->tmp_buffer = HeapAlloc(GetProcessHeap(), 0, - *frames * This->fmt->nBlockAlign); + HeapFree(GetProcessHeap(), 0, This->tmp_buffer); + This->tmp_buffer = HeapAlloc(GetProcessHeap(), 0, + *frames * This->fmt->nBlockAlign); if(!This->tmp_buffer){ LeaveCriticalSection(&This->lock); return E_OUTOFMEMORY;