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

dmstyle: Use CRT allocation functions.

parent 994bcb48
......@@ -77,9 +77,7 @@ static ULONG WINAPI audition_track_Release(IDirectMusicTrack8 *iface)
TRACE("(%p) ref=%ld\n", This, ref);
if (!ref) {
HeapFree(GetProcessHeap(), 0, This);
}
if (!ref) free(This);
return ref;
}
......@@ -320,11 +318,8 @@ HRESULT create_dmauditiontrack(REFIID lpcGUID, void **ppobj)
IDirectMusicAuditionTrack *track;
HRESULT hr;
track = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*track));
if (!track) {
*ppobj = NULL;
return E_OUTOFMEMORY;
}
if (!(track = calloc(1, sizeof(*track)))) return E_OUTOFMEMORY;
track->IDirectMusicTrack8_iface.lpVtbl = &dmtrack8_vtbl;
track->ref = 1;
dmobject_init(&track->dmobj, &CLSID_DirectMusicAuditionTrack,
......
......@@ -80,9 +80,7 @@ static ULONG WINAPI chord_track_Release(IDirectMusicTrack8 *iface)
TRACE("(%p) ref=%ld\n", This, ref);
if (!ref) {
HeapFree(GetProcessHeap(), 0, This);
}
if (!ref) free(This);
return ref;
}
......@@ -419,11 +417,8 @@ HRESULT create_dmchordtrack(REFIID lpcGUID, void **ppobj)
IDirectMusicChordTrack *track;
HRESULT hr;
track = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*track));
if (!track) {
*ppobj = NULL;
return E_OUTOFMEMORY;
}
if (!(track = calloc(1, sizeof(*track)))) return E_OUTOFMEMORY;
track->IDirectMusicTrack8_iface.lpVtbl = &dmtrack8_vtbl;
track->ref = 1;
dmobject_init(&track->dmobj, &CLSID_DirectMusicChordTrack,
......
......@@ -79,9 +79,7 @@ static ULONG WINAPI command_track_Release(IDirectMusicTrack8 *iface)
TRACE("(%p) ref=%ld\n", This, ref);
if (!ref) {
HeapFree(GetProcessHeap(), 0, This);
}
if (!ref) free(This);
return ref;
}
......@@ -302,7 +300,7 @@ static HRESULT WINAPI IPersistStreamImpl_Load(IPersistStream *iface, IStream *pS
nrCommands = chunkSize/dwSizeOfStruct; /* and this is the number of commands */
/* load each command separately in new entry */
for (count = 0; count < nrCommands; count++) {
LPDMUS_PRIVATE_COMMAND pNewCommand = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(DMUS_PRIVATE_COMMAND));
LPDMUS_PRIVATE_COMMAND pNewCommand = calloc(1, sizeof(*pNewCommand));
IStream_Read (pStm, &pNewCommand->pCommand, dwSizeOfStruct, NULL);
list_add_tail (&This->Commands, &pNewCommand->entry);
}
......@@ -372,11 +370,8 @@ HRESULT create_dmcommandtrack(REFIID lpcGUID, void **ppobj)
IDirectMusicCommandTrack *track;
HRESULT hr;
track = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*track));
if (!track) {
*ppobj = NULL;
return E_OUTOFMEMORY;
}
if (!(track = calloc(1, sizeof(*track)))) return E_OUTOFMEMORY;
track->IDirectMusicTrack8_iface.lpVtbl = &dmtrack8_vtbl;
track->ref = 1;
dmobject_init(&track->dmobj, &CLSID_DirectMusicCommandTrack,
......
......@@ -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;
}
......
......@@ -77,9 +77,7 @@ static ULONG WINAPI motif_track_Release(IDirectMusicTrack8 *iface)
TRACE("(%p) ref=%ld\n", This, ref);
if (!ref) {
HeapFree(GetProcessHeap(), 0, This);
}
if (!ref) free(This);
return ref;
}
......@@ -292,11 +290,8 @@ HRESULT create_dmmotiftrack(REFIID lpcGUID, void **ppobj)
IDirectMusicMotifTrack *track;
HRESULT hr;
track = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*track));
if (!track) {
*ppobj = NULL;
return E_OUTOFMEMORY;
}
if (!(track = calloc(1, sizeof(*track)))) return E_OUTOFMEMORY;
track->IDirectMusicTrack8_iface.lpVtbl = &dmtrack8_vtbl;
track->ref = 1;
dmobject_init(&track->dmobj, &CLSID_DirectMusicMotifTrack,
......
......@@ -77,9 +77,7 @@ static ULONG WINAPI mute_track_Release(IDirectMusicTrack8 *iface)
TRACE("(%p) ref=%ld\n", This, ref);
if (!ref) {
HeapFree(GetProcessHeap(), 0, This);
}
if (!ref) free(This);
return ref;
}
......@@ -301,11 +299,8 @@ HRESULT create_dmmutetrack(REFIID lpcGUID, void **ppobj)
IDirectMusicMuteTrack *track;
HRESULT hr;
track = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*track));
if (!track) {
*ppobj = NULL;
return E_OUTOFMEMORY;
}
if (!(track = calloc(1, sizeof(*track)))) return E_OUTOFMEMORY;
track->IDirectMusicTrack8_iface.lpVtbl = &dmtrack8_vtbl;
track->ref = 1;
dmobject_init(&track->dmobj, &CLSID_DirectMusicMuteTrack,
......
......@@ -20,7 +20,6 @@
#include "dmstyle_private.h"
#include "dmobject.h"
#include "wine/heap.h"
WINE_DEFAULT_DEBUG_CHANNEL(dmstyle);
WINE_DECLARE_DEBUG_CHANNEL(dmfile);
......@@ -116,17 +115,17 @@ static ULONG WINAPI IDirectMusicStyle8Impl_Release(IDirectMusicStyle8 *iface)
list_remove(&band->entry);
if (band->pBand)
IDirectMusicBand_Release(band->pBand);
heap_free(band);
free(band);
}
LIST_FOR_EACH_ENTRY_SAFE(motif, motif2, &This->motifs, struct style_motif, entry) {
list_remove(&motif->entry);
LIST_FOR_EACH_ENTRY_SAFE(item, item2, &motif->Items, struct style_partref_item, entry) {
list_remove(&item->entry);
heap_free(item);
free(item);
}
heap_free(motif);
free(motif);
}
heap_free(This);
free(This);
}
return ref;
......@@ -405,11 +404,7 @@ static HRESULT parse_part_ref_list(DMUS_PRIVATE_CHUNK *pChunk, IStream *pStm,
switch (Chunk.fccID) {
case DMUS_FOURCC_PARTREF_CHUNK: {
TRACE_(dmfile)(": PartRef chunk\n");
pNewItem = heap_alloc_zero(sizeof(*pNewItem));
if (!pNewItem) {
ERR(": no more memory\n");
return E_OUTOFMEMORY;
}
if (!(pNewItem = calloc(1, sizeof(*pNewItem)))) return E_OUTOFMEMORY;
hr = IStream_Read (pStm, &pNewItem->part_ref, sizeof(DMUS_IO_PARTREF), NULL);
/*TRACE_(dmfile)(" - sizeof %lu\n", sizeof(DMUS_IO_PARTREF));*/
list_add_tail (&pNewMotif->Items, &pNewItem->entry);
......@@ -630,11 +625,7 @@ static HRESULT parse_pattern_list(IDirectMusicStyle8Impl *This, DMUS_PRIVATE_CHU
case DMUS_FOURCC_PATTERN_CHUNK: {
TRACE_(dmfile)(": Pattern chunk\n");
/** alloc new motif entry */
pNewMotif = heap_alloc_zero(sizeof(*pNewMotif));
if (NULL == pNewMotif) {
ERR(": no more memory\n");
return E_OUTOFMEMORY;
}
if (!(pNewMotif = calloc(1, sizeof(*pNewMotif)))) return E_OUTOFMEMORY;
list_add_tail(&This->motifs, &pNewMotif->entry);
IStream_Read (pStm, &pNewMotif->pattern, Chunk.dwSize, NULL);
......@@ -826,11 +817,7 @@ static HRESULT parse_style_form(IDirectMusicStyle8Impl *This, DMUS_PRIVATE_CHUNK
return hr;
}
pNewBand = heap_alloc_zero(sizeof(*pNewBand));
if (NULL == pNewBand) {
ERR(": no more memory\n");
return E_OUTOFMEMORY;
}
if (!(pNewBand = calloc(1, sizeof(*pNewBand)))) return E_OUTOFMEMORY;
pNewBand->pBand = pBand;
IDirectMusicBand_AddRef(pBand);
list_add_tail(&This->bands, &pNewBand->entry);
......@@ -977,11 +964,8 @@ HRESULT create_dmstyle(REFIID lpcGUID, void **ppobj)
IDirectMusicStyle8Impl* obj;
HRESULT hr;
obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicStyle8Impl));
if (NULL == obj) {
*ppobj = NULL;
return E_OUTOFMEMORY;
}
if (!(obj = calloc(1, sizeof(*obj)))) return E_OUTOFMEMORY;
obj->IDirectMusicStyle8_iface.lpVtbl = &dmstyle8_vtbl;
obj->ref = 1;
dmobject_init(&obj->dmobj, &CLSID_DirectMusicStyle, (IUnknown *)&obj->IDirectMusicStyle8_iface);
......
......@@ -20,8 +20,6 @@
#include "dmstyle_private.h"
#include "dmobject.h"
#include "wine/heap.h"
WINE_DEFAULT_DEBUG_CHANNEL(dmstyle);
/*****************************************************************************
......@@ -95,7 +93,7 @@ static ULONG WINAPI style_track_Release(IDirectMusicTrack8 *iface)
free(item);
}
heap_free(This);
free(This);
}
return ref;
......@@ -390,11 +388,8 @@ HRESULT create_dmstyletrack(REFIID lpcGUID, void **ppobj)
IDirectMusicStyleTrack *track;
HRESULT hr;
track = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*track));
if (!track) {
*ppobj = NULL;
return E_OUTOFMEMORY;
}
if (!(track = calloc(1, sizeof(*track)))) return E_OUTOFMEMORY;
track->IDirectMusicTrack8_iface.lpVtbl = &dmtrack8_vtbl;
track->ref = 1;
dmobject_init(&track->dmobj, &CLSID_DirectMusicStyleTrack,
......
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