dmband: Use CRT allocation functions.

This commit is contained in:
Rémi Bernon 2023-09-09 09:16:50 +02:00 committed by Alexandre Julliard
parent c3ebc387f3
commit b60ee21fb2
3 changed files with 13 additions and 32 deletions

View file

@ -81,9 +81,7 @@ static ULONG WINAPI IDirectMusicBandImpl_Release(IDirectMusicBand *iface)
TRACE("(%p) ref=%ld\n", This, ref);
if (!ref) {
HeapFree(GetProcessHeap(), 0, This);
}
if (!ref) free(This);
return ref;
}
@ -277,11 +275,7 @@ static HRESULT parse_instrument(IDirectMusicBandImpl *This, DMUS_PRIVATE_CHUNK *
/*
* @TODO insert pNewInstrument into This
*/
pNewInstrument = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(DMUS_PRIVATE_INSTRUMENT));
if (NULL == pNewInstrument) {
ERR(": no more memory\n");
return E_OUTOFMEMORY;
}
if (!(pNewInstrument = calloc(1, sizeof(*pNewInstrument)))) return E_OUTOFMEMORY;
memcpy(&pNewInstrument->pInstrument, &inst, sizeof(DMUS_IO_INSTRUMENT));
pNewInstrument->ppReferenceCollection = NULL;
if (NULL != pObject) {
@ -289,8 +283,7 @@ static HRESULT parse_instrument(IDirectMusicBandImpl *This, DMUS_PRIVATE_CHUNK *
hr = IDirectMusicObject_QueryInterface (pObject, &IID_IDirectMusicCollection, (void**) &pCol);
if (FAILED(hr)) {
ERR(": failed to get IDirectMusicCollection Interface from DMObject\n");
HeapFree(GetProcessHeap(), 0, pNewInstrument);
free(pNewInstrument);
return hr;
}
pNewInstrument->ppReferenceCollection = pCol;
@ -514,11 +507,8 @@ HRESULT create_dmband(REFIID lpcGUID, void **ppobj)
IDirectMusicBandImpl* obj;
HRESULT hr;
obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicBandImpl));
if (NULL == obj) {
*ppobj = NULL;
return E_OUTOFMEMORY;
}
*ppobj = NULL;
if (!(obj = calloc(1, sizeof(*obj)))) return E_OUTOFMEMORY;
obj->IDirectMusicBand_iface.lpVtbl = &dmband_vtbl;
obj->ref = 1;
dmobject_init(&obj->dmobj, &CLSID_DirectMusicBand, (IUnknown *)&obj->IDirectMusicBand_iface);

View file

@ -80,9 +80,7 @@ static ULONG WINAPI band_track_Release(IDirectMusicTrack8 *iface)
TRACE("(%p) ref=%ld\n", This, ref);
if (!ref) {
HeapFree(GetProcessHeap(), 0, This);
}
if (!ref) free(This);
return ref;
}
@ -344,11 +342,8 @@ static HRESULT load_band(IDirectMusicBandTrack *This, IStream *pClonedStream,
* @TODO insert pBand into This
*/
if (SUCCEEDED(hr)) {
LPDMUS_PRIVATE_BAND pNewBand = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(DMUS_PRIVATE_BAND));
if (NULL == pNewBand) {
ERR(": no more memory\n");
return E_OUTOFMEMORY;
}
LPDMUS_PRIVATE_BAND pNewBand;
if (!(pNewBand = calloc(1, sizeof(*pNewBand)))) return E_OUTOFMEMORY;
pNewBand->BandHeader = *pHeader;
pNewBand->band = *ppBand;
IDirectMusicBand_AddRef(*ppBand);
@ -637,11 +632,8 @@ HRESULT create_dmbandtrack(REFIID lpcGUID, void **ppobj)
IDirectMusicBandTrack *track;
HRESULT hr;
track = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*track));
if (!track) {
*ppobj = NULL;
return E_OUTOFMEMORY;
}
*ppobj = NULL;
if (!(track = calloc(1, sizeof(*track)))) return E_OUTOFMEMORY;
track->IDirectMusicTrack8_iface.lpVtbl = &dmtrack8_vtbl;
track->ref = 1;
dmobject_init(&track->dmobj, &CLSID_DirectMusicBandTrack,

View file

@ -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;
}