Commit bd102523 authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

mmdevapi: Use CRT allocation functions.

parent 67ca3e71
......@@ -90,7 +90,7 @@ static ULONG WINAPI ASM_Release(IAudioSessionManager2 *iface)
TRACE("(%p) new ref %lu\n", This, ref);
if (!ref)
HeapFree(GetProcessHeap(), 0, This);
free(This);
return ref;
}
......@@ -192,7 +192,7 @@ HRESULT AudioSessionManager_Create(IMMDevice *device, IAudioSessionManager2 **pp
{
struct session_mgr *This;
This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*This));
This = calloc(1, sizeof(*This));
if (!This)
return E_OUTOFMEMORY;
......
......@@ -53,7 +53,7 @@ static inline AEVImpl *impl_from_IAudioEndpointVolumeEx(IAudioEndpointVolumeEx *
static void AudioEndpointVolume_Destroy(AEVImpl *This)
{
HeapFree(GetProcessHeap(), 0, This);
free(This);
}
static HRESULT WINAPI AEV_QueryInterface(IAudioEndpointVolumeEx *iface, REFIID riid, void **ppv)
......@@ -309,7 +309,7 @@ HRESULT AudioEndpointVolume_Create(MMDevice *parent, IAudioEndpointVolumeEx **pp
AEVImpl *This;
*ppv = NULL;
This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*This));
This = calloc(1, sizeof(*This));
if (!This)
return E_OUTOFMEMORY;
This->IAudioEndpointVolumeEx_iface.lpVtbl = &AEVImpl_Vtbl;
......
......@@ -460,7 +460,7 @@ static ULONG WINAPI client_Release(IAudioClient3 *iface)
if (This->stream)
stream_release(This->stream, This->timer_thread);
HeapFree(GetProcessHeap(), 0, This);
free(This);
}
return ref;
......@@ -1404,7 +1404,7 @@ HRESULT AudioClient_Create(GUID *guid, IMMDevice *device, IAudioClient **out)
}
size = strlen(name) + 1;
This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, FIELD_OFFSET(struct audio_client, device_name[size]));
This = calloc(1, FIELD_OFFSET(struct audio_client, device_name[size]));
if (!This) {
free(name);
return E_OUTOFMEMORY;
......@@ -1425,7 +1425,7 @@ HRESULT AudioClient_Create(GUID *guid, IMMDevice *device, IAudioClient **out)
hr = CoCreateFreeThreadedMarshaler((IUnknown *)&This->IAudioClient3_iface, &This->marshal);
if (FAILED(hr)) {
HeapFree(GetProcessHeap(), 0, This);
free(This);
return hr;
}
......
......@@ -336,7 +336,7 @@ static MMDevice *MMDevice_Create(WCHAR *name, GUID *id, EDataFlow flow, DWORD st
if(!cur){
/* No device found, allocate new one */
cur = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*cur));
cur = calloc(1, sizeof(*cur));
if (!cur)
return NULL;
......@@ -350,7 +350,7 @@ static MMDevice *MMDevice_Create(WCHAR *name, GUID *id, EDataFlow flow, DWORD st
}else if(cur->ref > 0)
WARN("Modifying an MMDevice with postitive reference count!\n");
HeapFree(GetProcessHeap(), 0, cur->drv_id);
free(cur->drv_id);
cur->drv_id = name;
cur->flow = flow;
......@@ -483,7 +483,7 @@ HRESULT load_devices_from_reg(void)
&& pv.vt == VT_LPWSTR)
{
DWORD size_bytes = (lstrlenW(pv.pwszVal) + 1) * sizeof(WCHAR);
WCHAR *name = HeapAlloc(GetProcessHeap(), 0, size_bytes);
WCHAR *name = malloc(size_bytes);
memcpy(name, pv.pwszVal, size_bytes);
MMDevice_Create(name, &guid, curflow,
DEVICE_STATE_NOTPRESENT, FALSE);
......@@ -536,16 +536,16 @@ HRESULT load_driver_devices(EDataFlow flow)
params.size = 1024;
params.endpoints = NULL;
do {
HeapFree(GetProcessHeap(), 0, params.endpoints);
params.endpoints = HeapAlloc(GetProcessHeap(), 0, params.size);
free(params.endpoints);
params.endpoints = malloc(params.size);
__wine_unix_call(drvs.module_unixlib, get_endpoint_ids, &params);
} while (params.result == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER));
if (FAILED(params.result))
goto end;
ids = HeapAlloc(GetProcessHeap(), 0, params.num * sizeof(*ids));
guids = HeapAlloc(GetProcessHeap(), 0, params.num * sizeof(*guids));
ids = malloc(params.num * sizeof(*ids));
guids = malloc(params.num * sizeof(*guids));
if (!ids || !guids) {
params.result = E_OUTOFMEMORY;
goto end;
......@@ -556,8 +556,8 @@ HRESULT load_driver_devices(EDataFlow flow)
const char *dev_name = (char *)params.endpoints + params.endpoints[i].device;
const unsigned int size = (wcslen(name) + 1) * sizeof(WCHAR);
if (!(ids[i] = HeapAlloc(GetProcessHeap(), 0, size))) {
while (i--) HeapFree(GetProcessHeap(), 0, ids[i]);
if (!(ids[i] = malloc(size))) {
while (i--) free(ids[i]);
params.result = E_OUTOFMEMORY;
goto end;
}
......@@ -573,9 +573,9 @@ HRESULT load_driver_devices(EDataFlow flow)
}
end:
HeapFree(GetProcessHeap(), 0, params.endpoints);
HeapFree(GetProcessHeap(), 0, guids);
HeapFree(GetProcessHeap(), 0, ids);
free(params.endpoints);
free(guids);
free(ids);
return params.result;
}
......@@ -586,8 +586,8 @@ static void MMDevice_Destroy(MMDevice *This)
list_remove(&This->entry);
This->crst.DebugInfo->Spare[0] = 0;
DeleteCriticalSection(&This->crst);
HeapFree(GetProcessHeap(), 0, This->drv_id);
HeapFree(GetProcessHeap(), 0, This);
free(This->drv_id);
free(This);
}
static inline MMDevice *impl_from_IMMDevice(IMMDevice *iface)
......@@ -828,7 +828,7 @@ static HRESULT MMDevCol_Create(IMMDeviceCollection **ppv, EDataFlow flow, DWORD
{
MMDevColImpl *This;
This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
This = malloc(sizeof(*This));
*ppv = NULL;
if (!This)
return E_OUTOFMEMORY;
......@@ -842,7 +842,7 @@ static HRESULT MMDevCol_Create(IMMDeviceCollection **ppv, EDataFlow flow, DWORD
static void MMDevCol_Destroy(MMDevColImpl *This)
{
HeapFree(GetProcessHeap(), 0, This);
free(This);
}
static HRESULT WINAPI MMDevCol_QueryInterface(IMMDeviceCollection *iface, REFIID riid, void **ppv)
......@@ -1288,7 +1288,7 @@ static HRESULT WINAPI MMDevEnum_RegisterEndpointNotificationCallback(IMMDeviceEn
if(!client)
return E_POINTER;
wrapper = HeapAlloc(GetProcessHeap(), 0, sizeof(*wrapper));
wrapper = malloc(sizeof(*wrapper));
if(!wrapper)
return E_OUTOFMEMORY;
......@@ -1324,7 +1324,7 @@ static HRESULT WINAPI MMDevEnum_UnregisterEndpointNotificationCallback(IMMDevice
LIST_FOR_EACH_ENTRY(wrapper, &g_notif_clients, struct NotificationClientWrapper, entry){
if(wrapper->client == client){
list_remove(&wrapper->entry);
HeapFree(GetProcessHeap(), 0, wrapper);
free(wrapper);
LeaveCriticalSection(&g_notif_lock);
return S_OK;
}
......@@ -1363,7 +1363,7 @@ static HRESULT MMDevPropStore_Create(MMDevice *parent, DWORD access, IPropertySt
WARN("Invalid access %08lx\n", access);
return E_INVALIDARG;
}
This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
This = malloc(sizeof(*This));
*ppv = &This->IPropertyStore_iface;
if (!This)
return E_OUTOFMEMORY;
......@@ -1376,7 +1376,7 @@ static HRESULT MMDevPropStore_Create(MMDevice *parent, DWORD access, IPropertySt
static void MMDevPropStore_Destroy(MMDevPropStore *This)
{
HeapFree(GetProcessHeap(), 0, This);
free(This);
}
static HRESULT WINAPI MMDevPropStore_QueryInterface(IPropertyStore *iface, REFIID riid, void **ppv)
......
......@@ -380,7 +380,7 @@ static ULONG WINAPI activate_async_op_Release(IActivateAudioInterfaceAsyncOperat
if(This->result_iface)
IUnknown_Release(This->result_iface);
IActivateAudioInterfaceCompletionHandler_Release(This->callback);
HeapFree(GetProcessHeap(), 0, This);
free(This);
}
return ref;
}
......@@ -477,7 +477,7 @@ HRESULT WINAPI ActivateAudioInterfaceAsync(const WCHAR *path, REFIID riid,
TRACE("(%s, %s, %p, %p, %p)\n", debugstr_w(path), debugstr_guid(riid),
params, done_handler, op_out);
op = HeapAlloc(GetProcessHeap(), 0, sizeof(*op));
op = malloc(sizeof(*op));
if (!op)
return E_OUTOFMEMORY;
......
......@@ -99,7 +99,7 @@ static ULONG WINAPI control_Release(IAudioSessionControl2 *iface)
IAudioClient3_Release(&This->client->IAudioClient3_iface);
}
HeapFree(GetProcessHeap(), 0, This);
free(This);
}
return ref;
......@@ -557,12 +557,7 @@ static void session_init_vols(struct audio_session *session, UINT channels)
if (session->channel_count < channels) {
UINT i;
if (session->channel_vols)
session->channel_vols = HeapReAlloc(GetProcessHeap(), 0, session->channel_vols,
sizeof(float) * channels);
else
session->channel_vols = HeapAlloc(GetProcessHeap(), 0, sizeof(float) * channels);
session->channel_vols = realloc(session->channel_vols, sizeof(float) * channels);
if (!session->channel_vols)
return;
......@@ -575,8 +570,7 @@ static void session_init_vols(struct audio_session *session, UINT channels)
static struct audio_session *session_create(const GUID *guid, IMMDevice *device, UINT channels)
{
struct audio_session *ret = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(struct audio_session));
struct audio_session *ret = calloc(1, sizeof(struct audio_session));
if (!ret)
return NULL;
......@@ -599,7 +593,7 @@ struct audio_session_wrapper *session_wrapper_create(struct audio_client *client
{
struct audio_session_wrapper *ret;
ret = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct audio_session_wrapper));
ret = calloc(1, sizeof(struct audio_session_wrapper));
if (!ret)
return NULL;
......
......@@ -24,7 +24,6 @@
#include "winbase.h"
#include "winnls.h"
#include "winreg.h"
#include "wine/heap.h"
#include "wine/debug.h"
#include "wine/list.h"
......@@ -160,8 +159,8 @@ static ULONG WINAPI SAO_Release(ISpatialAudioObject *iface)
LeaveCriticalSection(&This->sa_stream->lock);
ISpatialAudioObjectRenderStream_Release(&This->sa_stream->ISpatialAudioObjectRenderStream_iface);
heap_free(This->buf);
heap_free(This);
free(This->buf);
free(This);
}
return ref;
}
......@@ -288,11 +287,11 @@ static ULONG WINAPI SAORS_Release(ISpatialAudioObjectRenderStream *iface)
IAudioClient_Release(This->client);
if(This->params.NotifyObject)
ISpatialAudioObjectRenderStreamNotify_Release(This->params.NotifyObject);
heap_free((void*)This->params.ObjectFormat);
free((void*)This->params.ObjectFormat);
CloseHandle(This->params.EventHandle);
DeleteCriticalSection(&This->lock);
ISpatialAudioClient_Release(&This->sa_client->ISpatialAudioClient_iface);
heap_free(This);
free(This);
}
return ref;
}
......@@ -469,7 +468,7 @@ static HRESULT WINAPI SAORS_ActivateSpatialAudioObject(ISpatialAudioObjectRender
return SPTLAUDCLNT_E_OBJECT_ALREADY_ACTIVE;
}
obj = heap_alloc_zero(sizeof(*obj));
obj = calloc(1, sizeof(*obj));
obj->ISpatialAudioObject_iface.lpVtbl = &ISpatialAudioObject_vtbl;
obj->ref = 1;
obj->type = type;
......@@ -483,7 +482,7 @@ static HRESULT WINAPI SAORS_ActivateSpatialAudioObject(ISpatialAudioObjectRender
obj->sa_stream = This;
SAORS_AddRef(&This->ISpatialAudioObjectRenderStream_iface);
obj->buf = heap_alloc_zero(This->period_frames * This->sa_client->object_fmtex.Format.nBlockAlign);
obj->buf = calloc(This->period_frames, This->sa_client->object_fmtex.Format.nBlockAlign);
EnterCriticalSection(&This->lock);
......@@ -548,7 +547,7 @@ static ULONG WINAPI SAC_Release(ISpatialAudioClient *iface)
TRACE("(%p) new ref %lu\n", This, ref);
if (!ref) {
IMMDevice_Release(This->mmdev);
heap_free(This);
free(This);
}
return ref;
}
......@@ -626,7 +625,7 @@ static HRESULT WINAPI SAC_IsSpatialAudioStreamAvailable(ISpatialAudioClient *ifa
static WAVEFORMATEX *clone_fmtex(const WAVEFORMATEX *src)
{
WAVEFORMATEX *r = heap_alloc(sizeof(WAVEFORMATEX) + src->cbSize);
WAVEFORMATEX *r = malloc(sizeof(WAVEFORMATEX) + src->cbSize);
memcpy(r, src, sizeof(WAVEFORMATEX) + src->cbSize);
return r;
}
......@@ -783,7 +782,7 @@ static HRESULT WINAPI SAC_ActivateSpatialAudioStream(ISpatialAudioClient *iface,
return AUDCLNT_E_UNSUPPORTED_FORMAT;
}
obj = heap_alloc_zero(sizeof(SpatialAudioStreamImpl));
obj = calloc(1, sizeof(SpatialAudioStreamImpl));
obj->ISpatialAudioObjectRenderStream_iface.lpVtbl = &ISpatialAudioObjectRenderStream_vtbl;
obj->ref = 1;
......@@ -821,10 +820,10 @@ static HRESULT WINAPI SAC_ActivateSpatialAudioStream(ISpatialAudioClient *iface,
if(obj->params.NotifyObject)
ISpatialAudioObjectRenderStreamNotify_Release(obj->params.NotifyObject);
DeleteCriticalSection(&obj->lock);
heap_free((void*)obj->params.ObjectFormat);
free((void*)obj->params.ObjectFormat);
CloseHandle(obj->params.EventHandle);
ISpatialAudioClient_Release(&obj->sa_client->ISpatialAudioClient_iface);
heap_free(obj);
free(obj);
*stream = NULL;
return hr;
}
......@@ -913,7 +912,7 @@ HRESULT SpatialAudioClient_Create(IMMDevice *mmdev, ISpatialAudioClient **out)
WAVEFORMATEX *closest;
HRESULT hr;
obj = heap_alloc_zero(sizeof(*obj));
obj = calloc(1, sizeof(*obj));
obj->ref = 1;
obj->ISpatialAudioClient_iface.lpVtbl = &ISpatialAudioClient_vtbl;
......@@ -931,7 +930,7 @@ HRESULT SpatialAudioClient_Create(IMMDevice *mmdev, ISpatialAudioClient **out)
CLSCTX_INPROC_SERVER, NULL, (void**)&aclient);
if(FAILED(hr)){
WARN("Activate failed: %08lx\n", hr);
heap_free(obj);
free(obj);
return hr;
}
......@@ -943,7 +942,7 @@ HRESULT SpatialAudioClient_Create(IMMDevice *mmdev, ISpatialAudioClient **out)
if(sizeof(WAVEFORMATEX) + closest->cbSize > sizeof(obj->object_fmtex)){
ERR("Returned format too large: %s\n", debugstr_fmtex(closest));
CoTaskMemFree(closest);
heap_free(obj);
free(obj);
return AUDCLNT_E_UNSUPPORTED_FORMAT;
}else if(!((closest->wFormatTag == WAVE_FORMAT_IEEE_FLOAT ||
(closest->wFormatTag == WAVE_FORMAT_EXTENSIBLE &&
......@@ -952,7 +951,7 @@ HRESULT SpatialAudioClient_Create(IMMDevice *mmdev, ISpatialAudioClient **out)
closest->wBitsPerSample == 32)){
ERR("Returned format not 32-bit float: %s\n", debugstr_fmtex(closest));
CoTaskMemFree(closest);
heap_free(obj);
free(obj);
return AUDCLNT_E_UNSUPPORTED_FORMAT;
}
WARN("The audio stack doesn't support 48kHz 32bit float. Using the closest match. Audio may be glitchy. %s\n", debugstr_fmtex(closest));
......@@ -962,7 +961,7 @@ HRESULT SpatialAudioClient_Create(IMMDevice *mmdev, ISpatialAudioClient **out)
CoTaskMemFree(closest);
} else if(hr != S_OK){
WARN("Checking supported formats failed: %08lx\n", hr);
heap_free(obj);
free(obj);
return hr;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment