diff --git a/dlls/dmloader/container.c b/dlls/dmloader/container.c index 747c2a07341..66049e68907 100644 --- a/dlls/dmloader/container.c +++ b/dlls/dmloader/container.c @@ -136,7 +136,7 @@ static ULONG WINAPI IDirectMusicContainerImpl_Release(IDirectMusicContainer *ifa if (!ref) { if (This->pStream) destroy_dmcontainer(This); - HeapFree(GetProcessHeap(), 0, This); + free(This); } return ref; @@ -388,7 +388,7 @@ static HRESULT WINAPI IPersistStreamImpl_Load(IPersistStream *iface, IStream *pS case DMUS_FOURCC_CONTAINED_OBJECT_LIST: { LPWINE_CONTAINER_ENTRY pNewEntry; TRACE_(dmfile)(": contained object list\n"); - pNewEntry = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(WINE_CONTAINER_ENTRY)); + pNewEntry = calloc(1, sizeof(*pNewEntry)); DM_STRUCT_INIT(&pNewEntry->Desc); do { IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL); @@ -397,7 +397,7 @@ static HRESULT WINAPI IPersistStreamImpl_Load(IPersistStream *iface, IStream *pS switch (Chunk.fccID) { case DMUS_FOURCC_CONTAINED_ALIAS_CHUNK: { TRACE_(dmfile)(": alias chunk\n"); - pNewEntry->wszAlias = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, Chunk.dwSize); + pNewEntry->wszAlias = calloc(1, Chunk.dwSize); IStream_Read (pStm, pNewEntry->wszAlias, Chunk.dwSize, NULL); TRACE_(dmfile)(": alias: %s\n", debugstr_w(pNewEntry->wszAlias)); break; @@ -649,24 +649,21 @@ static const IPersistStreamVtbl persiststream_vtbl = { HRESULT create_dmcontainer(REFIID lpcGUID, void **ppobj) { IDirectMusicContainerImpl* obj; - HRESULT hr; + HRESULT hr; - obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicContainerImpl)); - if (NULL == obj) { - *ppobj = NULL; - return E_OUTOFMEMORY; - } - obj->IDirectMusicContainer_iface.lpVtbl = &dmcontainer_vtbl; - obj->ref = 1; - dmobject_init(&obj->dmobj, &CLSID_DirectMusicContainer, - (IUnknown*)&obj->IDirectMusicContainer_iface); - obj->dmobj.IDirectMusicObject_iface.lpVtbl = &dmobject_vtbl; - obj->dmobj.IPersistStream_iface.lpVtbl = &persiststream_vtbl; + *ppobj = NULL; + if (!(obj = calloc(1, sizeof(*obj)))) return E_OUTOFMEMORY; + obj->IDirectMusicContainer_iface.lpVtbl = &dmcontainer_vtbl; + obj->ref = 1; + dmobject_init(&obj->dmobj, &CLSID_DirectMusicContainer, + (IUnknown*)&obj->IDirectMusicContainer_iface); + obj->dmobj.IDirectMusicObject_iface.lpVtbl = &dmobject_vtbl; + obj->dmobj.IPersistStream_iface.lpVtbl = &persiststream_vtbl; obj->pContainedObjects = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(struct list)); list_init (obj->pContainedObjects); - hr = IDirectMusicContainer_QueryInterface(&obj->IDirectMusicContainer_iface, lpcGUID, ppobj); - IDirectMusicContainer_Release(&obj->IDirectMusicContainer_iface); + hr = IDirectMusicContainer_QueryInterface(&obj->IDirectMusicContainer_iface, lpcGUID, ppobj); + IDirectMusicContainer_Release(&obj->IDirectMusicContainer_iface); - return hr; + return hr; } diff --git a/dlls/dmloader/dmobject.c b/dlls/dmloader/dmobject.c index b526b23d031..07d887a376c 100644 --- a/dlls/dmloader/dmobject.c +++ b/dlls/dmloader/dmobject.c @@ -28,7 +28,6 @@ #include "dmusics.h" #include "dmobject.h" #include "wine/debug.h" -#include "wine/heap.h" WINE_DEFAULT_DEBUG_CHANNEL(dmobj); WINE_DECLARE_DEBUG_CHANNEL(dmfile); @@ -375,7 +374,7 @@ HRESULT stream_next_chunk(IStream *stream, struct chunk_entry *chunk) /* Reads chunk data of the form: DWORD - size of array element element[] - Array of elements - The caller needs to heap_free() the array. + The caller needs to free() the array. */ HRESULT stream_chunk_get_array(IStream *stream, const struct chunk_entry *chunk, void **array, unsigned int *count, DWORD elem_size) @@ -400,10 +399,10 @@ HRESULT stream_chunk_get_array(IStream *stream, const struct chunk_entry *chunk, *count = (chunk->size - sizeof(DWORD)) / elem_size; size = *count * elem_size; - if (!(*array = heap_alloc(size))) + if (!(*array = malloc(size))) return E_OUTOFMEMORY; if (FAILED(hr = stream_read(stream, *array, size))) { - heap_free(*array); + free(*array); *array = NULL; return hr; } diff --git a/dlls/dmloader/loader.c b/dlls/dmloader/loader.c index f303f93baaa..7b1fb8d04a5 100644 --- a/dlls/dmloader/loader.c +++ b/dlls/dmloader/loader.c @@ -155,8 +155,8 @@ static ULONG WINAPI IDirectMusicLoaderImpl_Release(IDirectMusicLoader8 *iface) IDirectMusicLoader8_ClearCache(iface, &GUID_DirectMusicAllTypes); for (i = 0; i < ARRAY_SIZE(classes); i++) - HeapFree(GetProcessHeap(), 0, This->search_paths[i]); - HeapFree(GetProcessHeap(), 0, This); + free(This->search_paths[i]); + free(This); } return ref; @@ -427,7 +427,7 @@ static HRESULT WINAPI IDirectMusicLoaderImpl_GetObject(IDirectMusicLoader8 *ifac bCache = is_cache_enabled(This, &pDesc->guidClass); if (bCache) { if (!pObjectEntry) { - pObjectEntry = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(*pObjectEntry)); + pObjectEntry = calloc(1, sizeof(*pObjectEntry)); DM_STRUCT_INIT(&pObjectEntry->Desc); DMUSIC_CopyDescriptor (&pObjectEntry->Desc, &GotDesc); pObjectEntry->pObject = pObject; @@ -566,7 +566,7 @@ static HRESULT WINAPI IDirectMusicLoaderImpl_SetObject(IDirectMusicLoader8 *ifac TRACE(": adding alias entry with following info:\n"); if (TRACE_ON(dmloader)) dump_DMUS_OBJECTDESC(pDesc); - pNewEntry = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(*pNewEntry)); + pNewEntry = calloc(1, sizeof(*pNewEntry)); /* use this function instead of pure memcpy due to streams (memcpy just copies pointer), which is basically used further by app that called SetDescriptor... better safety than exception */ DMUSIC_CopyDescriptor (&pNewEntry->Desc, pDesc); @@ -601,7 +601,7 @@ static HRESULT WINAPI IDirectMusicLoaderImpl_SetSearchDirectory(IDirectMusicLoad return S_OK; if (!This->search_paths[index]) - This->search_paths[index] = HeapAlloc(GetProcessHeap(), 0, MAX_PATH); + This->search_paths[index] = malloc(MAX_PATH); else if (!wcsncmp(This->search_paths[index], path, MAX_PATH)) return S_FALSE; @@ -743,7 +743,7 @@ static HRESULT WINAPI IDirectMusicLoaderImpl_ClearCache(IDirectMusicLoader8 *ifa /* basically, wrap to ReleaseObject for each object found */ IDirectMusicLoader8_ReleaseObject(iface, obj->pObject); list_remove(&obj->entry); - HeapFree(GetProcessHeap(), 0, obj); + free(obj); } } @@ -910,11 +910,8 @@ HRESULT create_dmloader(REFIID lpcGUID, void **ppobj) struct list *pEntry; TRACE("(%s, %p)\n", debugstr_dmguid(lpcGUID), ppobj); - obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicLoaderImpl)); - if (NULL == obj) { - *ppobj = NULL; - return E_OUTOFMEMORY; - } + *ppobj = NULL; + if (!(obj = calloc(1, sizeof(*obj)))) return E_OUTOFMEMORY; obj->IDirectMusicLoader8_iface.lpVtbl = &DirectMusicLoader_Loader_Vtbl; obj->ref = 0; /* Will be inited with QueryInterface */ list_init(&obj->cache); diff --git a/dlls/dmloader/loaderstream.c b/dlls/dmloader/loaderstream.c index 889070be8f6..5d6c5ad3e25 100644 --- a/dlls/dmloader/loaderstream.c +++ b/dlls/dmloader/loaderstream.c @@ -120,7 +120,7 @@ static ULONG WINAPI IDirectMusicLoaderFileStream_IStream_Release (LPSTREAM iface if (dwRef == 0) { if (This->hFile) IDirectMusicLoaderFileStream_Detach (iface); - HeapFree (GetProcessHeap(), 0, This); + free(This); } return dwRef; @@ -290,11 +290,9 @@ HRESULT DMUSIC_CreateDirectMusicLoaderFileStream (void** ppobj) { IDirectMusicLoaderFileStream *obj; TRACE("(%p)\n", ppobj); - obj = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(IDirectMusicLoaderFileStream)); - if (NULL == obj) { - *ppobj = NULL; - return E_OUTOFMEMORY; - } + + *ppobj = NULL; + if (!(obj = calloc(1, sizeof(*obj)))) return E_OUTOFMEMORY; obj->StreamVtbl = &DirectMusicLoaderFileStream_Stream_Vtbl; obj->GetLoaderVtbl = &DirectMusicLoaderFileStream_GetLoader_Vtbl; obj->dwRef = 0; /* will be inited with QueryInterface */ @@ -367,7 +365,7 @@ static ULONG WINAPI IDirectMusicLoaderResourceStream_IStream_Release (LPSTREAM i TRACE("(%p): ReleaseRef to %ld\n", This, dwRef); if (dwRef == 0) { IDirectMusicLoaderResourceStream_Detach (iface); - HeapFree (GetProcessHeap(), 0, This); + free(This); } return dwRef; @@ -547,11 +545,9 @@ HRESULT DMUSIC_CreateDirectMusicLoaderResourceStream (void** ppobj) { IDirectMusicLoaderResourceStream *obj; TRACE("(%p)\n", ppobj); - obj = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(IDirectMusicLoaderResourceStream)); - if (NULL == obj) { - *ppobj = NULL; - return E_OUTOFMEMORY; - } + + *ppobj = NULL; + if (!(obj = calloc(1, sizeof(*obj)))) return E_OUTOFMEMORY; obj->StreamVtbl = &DirectMusicLoaderResourceStream_Stream_Vtbl; obj->GetLoaderVtbl = &DirectMusicLoaderResourceStream_GetLoader_Vtbl; obj->dwRef = 0; /* will be inited with QueryInterface */ @@ -799,11 +795,9 @@ HRESULT DMUSIC_CreateDirectMusicLoaderGenericStream (void** ppobj) { IDirectMusicLoaderGenericStream *obj; TRACE("(%p)\n", ppobj); - obj = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(IDirectMusicLoaderGenericStream)); - if (NULL == obj) { - *ppobj = NULL; - return E_OUTOFMEMORY; - } + + *ppobj = NULL; + if (!(obj = calloc(1, sizeof(*obj)))) return E_OUTOFMEMORY; obj->StreamVtbl = &DirectMusicLoaderGenericStream_Stream_Vtbl; obj->GetLoaderVtbl = &DirectMusicLoaderGenericStream_GetLoader_Vtbl; obj->dwRef = 0; /* will be inited with QueryInterface */