[RFC PATCH 5/5] xaudio2_7: Use msvcrt allocation functions.

Rémi Bernon rbernon at codeweavers.com
Wed Jun 23 07:37:27 CDT 2021


Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
 dlls/xaudio2_7/compat.c     | 26 +++++++++++++-------------
 dlls/xaudio2_7/xact_dll.c   | 30 +++++++++++++++---------------
 dlls/xaudio2_7/xapo.c       | 13 ++++++-------
 dlls/xaudio2_7/xaudio_dll.c | 31 +++++++++++++++----------------
 4 files changed, 49 insertions(+), 51 deletions(-)

diff --git a/dlls/xaudio2_7/compat.c b/dlls/xaudio2_7/compat.c
index 45adcd41407..5d9daff67de 100644
--- a/dlls/xaudio2_7/compat.c
+++ b/dlls/xaudio2_7/compat.c
@@ -109,7 +109,7 @@ static XAUDIO2_SEND_DESCRIPTOR *convert_send_descriptors23(const XAUDIO23_VOICE_
     XAUDIO2_SEND_DESCRIPTOR *ret;
     DWORD i;
 
-    ret = HeapAlloc(GetProcessHeap(), 0, sends->OutputCount * sizeof(XAUDIO2_SEND_DESCRIPTOR));
+    ret = malloc(sends->OutputCount * sizeof(XAUDIO2_SEND_DESCRIPTOR));
 
     for(i = 0; i < sends->OutputCount; ++i){
         ret[i].Flags = 0;
@@ -158,7 +158,7 @@ static HRESULT WINAPI XA20SRC_SetOutputVoices(IXAudio20SourceVoice *iface,
     hr = IXAudio2SourceVoice_SetOutputVoices(&This->IXAudio2SourceVoice_iface, psends);
 
     if(pSendList)
-        HeapFree(GetProcessHeap(), 0, sends.pSends);
+        free(sends.pSends);
 
     return hr;
 }
@@ -415,7 +415,7 @@ static HRESULT WINAPI XA23SRC_SetOutputVoices(IXAudio23SourceVoice *iface,
     hr = IXAudio2SourceVoice_SetOutputVoices(&This->IXAudio2SourceVoice_iface, psends);
 
     if(pSendList)
-        HeapFree(GetProcessHeap(), 0, sends.pSends);
+        free(sends.pSends);
 
     return hr;
 }
@@ -935,7 +935,7 @@ static HRESULT WINAPI XA20SUB_SetOutputVoices(IXAudio20SubmixVoice *iface,
     hr = IXAudio2SubmixVoice_SetOutputVoices(&This->IXAudio2SubmixVoice_iface, psends);
 
     if(pSendList)
-        HeapFree(GetProcessHeap(), 0, sends.pSends);
+        free(sends.pSends);
 
     return hr;
 }
@@ -1120,7 +1120,7 @@ static HRESULT WINAPI XA23SUB_SetOutputVoices(IXAudio23SubmixVoice *iface,
     hr = IXAudio2SubmixVoice_SetOutputVoices(&This->IXAudio2SubmixVoice_iface, psends);
 
     if(pSendList)
-        HeapFree(GetProcessHeap(), 0, sends.pSends);
+        free(sends.pSends);
 
     return hr;
 }
@@ -1495,7 +1495,7 @@ static HRESULT WINAPI XA20M_SetOutputVoices(IXAudio20MasteringVoice *iface,
     hr = IXAudio2MasteringVoice_SetOutputVoices(&This->IXAudio2MasteringVoice_iface, psends);
 
     if(pSendList)
-        HeapFree(GetProcessHeap(), 0, sends.pSends);
+        free(sends.pSends);
 
     return hr;
 }
@@ -1680,7 +1680,7 @@ static HRESULT WINAPI XA23M_SetOutputVoices(IXAudio23MasteringVoice *iface,
     hr = IXAudio2MasteringVoice_SetOutputVoices(&This->IXAudio2MasteringVoice_iface, psends);
 
     if(pSendList)
-        HeapFree(GetProcessHeap(), 0, sends.pSends);
+        free(sends.pSends);
 
     return hr;
 }
@@ -2101,7 +2101,7 @@ static HRESULT WINAPI XA20_CreateSourceVoice(IXAudio20 *iface,
             pEffectChain);
 
     if(pSendList)
-        HeapFree(GetProcessHeap(), 0, sends.pSends);
+        free(sends.pSends);
 
     return hr;
 }
@@ -2127,7 +2127,7 @@ static HRESULT WINAPI XA20_CreateSubmixVoice(IXAudio20 *iface,
             pEffectChain);
 
     if(pSendList)
-        HeapFree(GetProcessHeap(), 0, sends.pSends);
+        free(sends.pSends);
 
     return hr;
 }
@@ -2326,7 +2326,7 @@ static HRESULT WINAPI XA22_CreateSourceVoice(IXAudio22 *iface,
             pEffectChain);
 
     if(pSendList)
-        HeapFree(GetProcessHeap(), 0, sends.pSends);
+        free(sends.pSends);
 
     return hr;
 }
@@ -2352,7 +2352,7 @@ static HRESULT WINAPI XA22_CreateSubmixVoice(IXAudio22 *iface,
             pEffectChain);
 
     if(pSendList)
-        HeapFree(GetProcessHeap(), 0, sends.pSends);
+        free(sends.pSends);
 
     return hr;
 }
@@ -2550,7 +2550,7 @@ static HRESULT WINAPI XA23_CreateSourceVoice(IXAudio23 *iface,
             pEffectChain);
 
     if(pSendList)
-        HeapFree(GetProcessHeap(), 0, sends.pSends);
+        free(sends.pSends);
 
     return hr;
 }
@@ -2576,7 +2576,7 @@ static HRESULT WINAPI XA23_CreateSubmixVoice(IXAudio23 *iface,
             pEffectChain);
 
     if(pSendList)
-        HeapFree(GetProcessHeap(), 0, sends.pSends);
+        free(sends.pSends);
 
     return hr;
 }
diff --git a/dlls/xaudio2_7/xact_dll.c b/dlls/xaudio2_7/xact_dll.c
index 59ef6ab740d..fae997c9779 100644
--- a/dlls/xaudio2_7/xact_dll.c
+++ b/dlls/xaudio2_7/xact_dll.c
@@ -95,7 +95,7 @@ static HRESULT WINAPI IXACT3CueImpl_Destroy(IXACT3Cue *iface)
     ret = pFACTCue_Destroy(This->fact_cue);
     if (ret != 0)
         WARN("pFACTCue_Destroy returned %d\n", ret);
-    HeapFree(GetProcessHeap(), 0, This);
+    free(This);
     return S_OK;
 }
 
@@ -313,7 +313,7 @@ static HRESULT WINAPI IXACT3SoundBankImpl_Prepare(IXACT3SoundBank *iface,
         return E_FAIL;
     }
 
-    cue = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*cue));
+    cue = calloc(1, sizeof(*cue));
     if (!cue)
     {
         pFACTCue_Destroy(fcue);
@@ -355,7 +355,7 @@ static HRESULT WINAPI IXACT3SoundBankImpl_Play(IXACT3SoundBank *iface,
         if(FAILED(hr))
             return hr;
 
-        cue = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*cue));
+        cue = calloc(1, sizeof(*cue));
         if (!cue)
         {
             pFACTCue_Destroy(fcue);
@@ -389,7 +389,7 @@ static HRESULT WINAPI IXACT3SoundBankImpl_Destroy(IXACT3SoundBank *iface)
     TRACE("(%p)\n", This);
 
     hr = pFACTSoundBank_Destroy(This->fact_soundbank);
-    HeapFree(GetProcessHeap(), 0, This);
+    free(This);
     return hr;
 }
 
@@ -438,7 +438,7 @@ static HRESULT WINAPI IXACT3WaveImpl_Destroy(IXACT3Wave *iface)
     TRACE("(%p)\n", This);
 
     hr = pFACTWave_Destroy(This->fact_wave);
-    HeapFree(GetProcessHeap(), 0, This);
+    free(This);
     return hr;
 }
 
@@ -554,7 +554,7 @@ static HRESULT WINAPI IXACT3WaveBankImpl_Destroy(IXACT3WaveBank *iface)
     TRACE("(%p)\n", This);
 
     hr = pFACTWaveBank_Destroy(This->fact_wavebank);
-    HeapFree(GetProcessHeap(), 0, This);
+    free(This);
     return hr;
 }
 
@@ -611,7 +611,7 @@ static HRESULT WINAPI IXACT3WaveBankImpl_Prepare(IXACT3WaveBank *iface,
         return E_FAIL;
     }
 
-    wave = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*wave));
+    wave = calloc(1, sizeof(*wave));
     if (!wave)
     {
         pFACTWave_Destroy(fwave);
@@ -653,7 +653,7 @@ static HRESULT WINAPI IXACT3WaveBankImpl_Play(IXACT3WaveBank *iface,
         if(FAILED(hr))
             return hr;
 
-        wave = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*wave));
+        wave = calloc(1, sizeof(*wave));
         if (!wave)
         {
             pFACTWave_Destroy(fwave);
@@ -788,7 +788,7 @@ static ULONG WINAPI IXACT3EngineImpl_Release(IXACT3Engine *iface)
     TRACE("(%p)->(): Refcount now %u\n", This, ref);
 
     if (!ref)
-        HeapFree(GetProcessHeap(), 0, This);
+        free(This);
     return ref;
 }
 
@@ -943,7 +943,7 @@ static HRESULT WINAPI IXACT3EngineImpl_CreateSoundBank(IXACT3Engine *iface,
         return E_FAIL;
     }
 
-    sb = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*sb));
+    sb = calloc(1, sizeof(*sb));
     if (!sb)
     {
         pFACTSoundBank_Destroy(fsb);
@@ -980,7 +980,7 @@ static HRESULT WINAPI IXACT3EngineImpl_CreateInMemoryWaveBank(IXACT3Engine *ifac
         return E_FAIL;
     }
 
-    wb = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*wb));
+    wb = calloc(1, sizeof(*wb));
     if (!wb)
     {
         pFACTWaveBank_Destroy(fwb);
@@ -1028,7 +1028,7 @@ static HRESULT WINAPI IXACT3EngineImpl_CreateStreamingWaveBank(IXACT3Engine *ifa
         return E_FAIL;
     }
 
-    wb = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*wb));
+    wb = calloc(1, sizeof(*wb));
     if (!wb)
     {
         pFACTWaveBank_Destroy(fwb);
@@ -1089,7 +1089,7 @@ static HRESULT WINAPI IXACT3EngineImpl_PrepareWave(IXACT3Engine *iface,
         return E_FAIL;
     }
 
-    wave = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*wave));
+    wave = calloc(1, sizeof(*wave));
     if (!wave)
     {
         pFACTWave_Destroy(fwave);
@@ -1414,7 +1414,7 @@ static HRESULT WINAPI XACT3CF_CreateInstance(IClassFactory *iface, IUnknown *pOu
     if(pOuter)
         return CLASS_E_NOAGGREGATION;
 
-    object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
+    object = calloc(1, sizeof(*object));
     if(!object)
         return E_OUTOFMEMORY;
 
@@ -1430,7 +1430,7 @@ static HRESULT WINAPI XACT3CF_CreateInstance(IClassFactory *iface, IUnknown *pOu
 
     hr = IXACT3Engine_QueryInterface(&object->IXACT3Engine_iface, riid, ppobj);
     if(FAILED(hr)){
-        HeapFree(GetProcessHeap(), 0, object);
+        free(object);
         return hr;
     }
 
diff --git a/dlls/xaudio2_7/xapo.c b/dlls/xaudio2_7/xapo.c
index 1b0ae8639cf..6a4f64a38ef 100644
--- a/dlls/xaudio2_7/xapo.c
+++ b/dlls/xaudio2_7/xapo.c
@@ -28,7 +28,6 @@
 #include "xapofx.h"
 
 #include "wine/debug.h"
-#include "wine/heap.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(xaudio2);
 
@@ -82,7 +81,7 @@ static ULONG WINAPI XAPOFX_Release(IXAPO *iface)
     TRACE("(%p)->(): Refcount now %u\n", This, ref);
 
     if(!ref)
-        HeapFree(GetProcessHeap(), 0, This);
+        free(This);
 
     return ref;
 }
@@ -292,7 +291,7 @@ static ULONG WINAPI xapocf_Release(IClassFactory *iface)
     ULONG ref = InterlockedDecrement(&This->ref);
     TRACE("(%p)->(): Refcount now %u\n", This, ref);
     if (!ref)
-        HeapFree(GetProcessHeap(), 0, This);
+        free(This);
     return ref;
 }
 
@@ -360,14 +359,14 @@ static HRESULT WINAPI xapocf_CreateInstance(IClassFactory *iface, IUnknown *pOut
     if(pOuter)
         return CLASS_E_NOAGGREGATION;
 
-    object = heap_alloc(sizeof(*object));
+    object = malloc(sizeof(*object));
     object->IXAPO_iface.lpVtbl = &XAPOFX_Vtbl;
     object->IXAPOParameters_iface.lpVtbl = &XAPOFXParameters_Vtbl;
 
     hr = get_fapo_from_clsid(This->class, &object->fapo);
 
     if(FAILED(hr)){
-        HeapFree(GetProcessHeap(), 0, object);
+        free(object);
         return hr;
     }
 
@@ -396,12 +395,12 @@ static const IClassFactoryVtbl xapo_Vtbl =
 HRESULT make_xapo_factory(REFCLSID clsid, REFIID riid, void **ppv)
 {
     HRESULT hr;
-    struct xapo_cf *ret = HeapAlloc(GetProcessHeap(), 0, sizeof(struct xapo_cf));
+    struct xapo_cf *ret = malloc(sizeof(struct xapo_cf));
     ret->IClassFactory_iface.lpVtbl = &xapo_Vtbl;
     ret->class = clsid;
     ret->ref = 0;
     hr = IClassFactory_QueryInterface(&ret->IClassFactory_iface, riid, ppv);
     if(FAILED(hr))
-        HeapFree(GetProcessHeap(), 0, ret);
+        free(ret);
     return hr;
 }
diff --git a/dlls/xaudio2_7/xaudio_dll.c b/dlls/xaudio2_7/xaudio_dll.c
index 21bd57b4587..638bfedd3b7 100644
--- a/dlls/xaudio2_7/xaudio_dll.c
+++ b/dlls/xaudio2_7/xaudio_dll.c
@@ -35,7 +35,6 @@
 
 #include "wine/asm.h"
 #include "wine/debug.h"
-#include "wine/heap.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(xaudio2);
 
@@ -119,7 +118,7 @@ static int32_t FAPOCALL XAPO_Release(void *iface)
         IXAPO_Release(This->xapo);
         if(This->xapo_params)
             IXAPOParameters_Release(This->xapo_params);
-        heap_free(This);
+        free(This);
     }
     return r;
 }
@@ -295,7 +294,7 @@ static XA2XAPOImpl *wrap_xapo(IUnknown *unk)
         xapo_params = NULL;
     }
 
-    ret = heap_alloc(sizeof(*ret));
+    ret = malloc(sizeof(*ret));
 
     ret->xapo = xapo;
     ret->xapo_params = xapo_params;
@@ -315,7 +314,7 @@ FAudioEffectChain *wrap_effect_chain(const XAUDIO2_EFFECT_CHAIN *pEffectChain)
     if(!pEffectChain)
         return NULL;
 
-    ret = heap_alloc(sizeof(*ret) + sizeof(FAudioEffectDescriptor) * pEffectChain->EffectCount);
+    ret = malloc(sizeof(*ret) + sizeof(FAudioEffectDescriptor) * pEffectChain->EffectCount);
 
     ret->EffectCount = pEffectChain->EffectCount;
     ret->pEffectDescriptors = (void*)(ret + 1);
@@ -336,7 +335,7 @@ static void free_effect_chain(FAudioEffectChain *chain)
         return;
     for(i = 0; i < chain->EffectCount; ++i)
         XAPO_Release(chain->pEffectDescriptors[i].pEffect);
-    heap_free(chain);
+    free(chain);
 }
 
 /* Send Wrapping */
@@ -349,7 +348,7 @@ static FAudioVoiceSends *wrap_voice_sends(const XAUDIO2_VOICE_SENDS *sends)
     if(!sends)
         return NULL;
 
-    ret = heap_alloc(sizeof(*ret) + sends->SendCount * sizeof(FAudioSendDescriptor));
+    ret = malloc(sizeof(*ret) + sends->SendCount * sizeof(FAudioSendDescriptor));
     ret->SendCount = sends->SendCount;
     ret->pSends = (FAudioSendDescriptor*)(ret + 1);
     for(i = 0; i < sends->SendCount; ++i){
@@ -364,7 +363,7 @@ static void free_voice_sends(FAudioVoiceSends *sends)
 {
     if(!sends)
         return;
-    heap_free(sends);
+    free(sends);
 }
 
 /* Voice Callbacks */
@@ -1423,15 +1422,15 @@ static ULONG WINAPI IXAudio2Impl_Release(IXAudio2 *iface)
         LIST_FOR_EACH_ENTRY_SAFE(v, v2, &This->voices, XA2VoiceImpl, entry){
             v->lock.DebugInfo->Spare[0] = 0;
             DeleteCriticalSection(&v->lock);
-            HeapFree(GetProcessHeap(), 0, v);
+            free(v);
         }
 
-        HeapFree(GetProcessHeap(), 0, This->cbs);
+        free(This->cbs);
 
         This->lock.DebugInfo->Spare[0] = 0;
         DeleteCriticalSection(&This->lock);
 
-        HeapFree(GetProcessHeap(), 0, This);
+        free(This);
     }
     return ref;
 }
@@ -1455,7 +1454,7 @@ static HRESULT WINAPI IXAudio2Impl_RegisterForCallbacks(IXAudio2 *iface,
     }
 
     This->ncbs++;
-    This->cbs = heap_realloc(This->cbs, This->ncbs * sizeof(*This->cbs));
+    This->cbs = realloc(This->cbs, This->ncbs * sizeof(*This->cbs));
 
     This->cbs[i] = pCallback;
 
@@ -1497,7 +1496,7 @@ static inline XA2VoiceImpl *create_voice(IXAudio2Impl *This)
 {
     XA2VoiceImpl *voice;
 
-    voice = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*voice));
+    voice = calloc(1, sizeof(*voice));
     if(!voice)
         return NULL;
 
@@ -1805,7 +1804,7 @@ static ULONG WINAPI XAudio2CF_Release(IClassFactory *iface)
     ULONG ref = InterlockedDecrement(&This->ref);
     TRACE("(%p)->(): Refcount now %u\n", This, ref);
     if (!ref)
-        HeapFree(GetProcessHeap(), 0, This);
+        free(This);
     return ref;
 }
 
@@ -1823,7 +1822,7 @@ static HRESULT WINAPI XAudio2CF_CreateInstance(IClassFactory *iface, IUnknown *p
     if(pOuter)
         return CLASS_E_NOAGGREGATION;
 
-    object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
+    object = calloc(1, sizeof(*object));
     if(!object)
         return E_OUTOFMEMORY;
 
@@ -1901,12 +1900,12 @@ static const IClassFactoryVtbl XAudio2CF_Vtbl =
 static inline HRESULT make_xaudio2_factory(REFIID riid, void **ppv)
 {
     HRESULT hr;
-    struct xaudio2_cf *ret = HeapAlloc(GetProcessHeap(), 0, sizeof(struct xaudio2_cf));
+    struct xaudio2_cf *ret = malloc(sizeof(struct xaudio2_cf));
     ret->IClassFactory_iface.lpVtbl = &XAudio2CF_Vtbl;
     ret->ref = 0;
     hr = IClassFactory_QueryInterface(&ret->IClassFactory_iface, riid, ppv);
     if(FAILED(hr))
-        HeapFree(GetProcessHeap(), 0, ret);
+        free(ret);
     return hr;
 }
 
-- 
2.31.0




More information about the wine-devel mailing list