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