Commit 307b13bc authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

dmloader: Use CRT allocation functions.

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