From 898c2954e012d1e70b692ddb07f551c4128b6e0e Mon Sep 17 00:00:00 2001 From: Christian Costa Date: Fri, 21 Dec 2012 10:27:46 +0100 Subject: [PATCH] dmusic: Use static variables for instrument header and id instead of using pointer. --- dlls/dmusic/collection.c | 20 +++++++++----------- dlls/dmusic/dmusic_private.h | 4 ++-- dlls/dmusic/instrument.c | 6 +++--- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/dlls/dmusic/collection.c b/dlls/dmusic/collection.c index 5002c9e5f4..e30f89d121 100644 --- a/dlls/dmusic/collection.c +++ b/dlls/dmusic/collection.c @@ -662,7 +662,7 @@ static HRESULT WINAPI IDirectMusicCollectionImpl_IPersistStream_Load(LPPERSISTST LPDMUS_PRIVATE_INSTRUMENTENTRY new_instrument = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DMUS_PRIVATE_INSTRUMENTENTRY)); TRACE_(dmfile)(": instrument list\n"); /* Only way to create this one... even M$ does it discretely */ - DMUSIC_CreateDirectMusicInstrumentImpl(&IID_IDirectMusicInstrument, (LPVOID*)&new_instrument->pInstrument, NULL); + DMUSIC_CreateDirectMusicInstrumentImpl(&IID_IDirectMusicInstrument, (void**)&new_instrument->pInstrument, NULL); { IDirectMusicInstrumentImpl *instrument = impl_from_IDirectMusicInstrument(new_instrument->pInstrument); /* Store offset and length, they will be needed when loading the instrument */ @@ -677,14 +677,12 @@ static HRESULT WINAPI IDirectMusicCollectionImpl_IPersistStream_Load(LPPERSISTST switch (chunk.fccID) { case FOURCC_INSH: { TRACE_(dmfile)(": instrument header chunk\n"); - instrument->pHeader = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, chunk.dwSize); - IStream_Read(stream, instrument->pHeader, chunk.dwSize, NULL); + IStream_Read(stream, &instrument->header, chunk.dwSize, NULL); break; } case FOURCC_DLID: { TRACE_(dmfile)(": DLID (GUID) chunk\n"); - instrument->pInstrumentID = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, chunk.dwSize); - IStream_Read(stream, instrument->pInstrumentID, chunk.dwSize, NULL); + IStream_Read(stream, &instrument->id, chunk.dwSize, NULL); break; } case FOURCC_LIST: { @@ -712,14 +710,14 @@ static HRESULT WINAPI IDirectMusicCollectionImpl_IPersistStream_Load(LPPERSISTST /* DEBUG: dumps whole instrument object tree: */ if (TRACE_ON(dmusic)) { TRACE("*** IDirectMusicInstrument (%p) ***\n", instrument); - if (instrument->pInstrumentID) - TRACE(" - GUID = %s\n", debugstr_dmguid(instrument->pInstrumentID)); + if (!IsEqualGUID(&instrument->id, &GUID_NULL)) + TRACE(" - GUID = %s\n", debugstr_dmguid(&instrument->id)); TRACE(" - Instrument header:\n"); - TRACE(" - cRegions: %d\n", instrument->pHeader->cRegions); + TRACE(" - cRegions: %d\n", instrument->header.cRegions); TRACE(" - Locale:\n"); - TRACE(" - ulBank: %d\n", instrument->pHeader->Locale.ulBank); - TRACE(" - ulInstrument: %d\n", instrument->pHeader->Locale.ulInstrument); - TRACE(" => dwPatch: %d\n", MIDILOCALE2Patch(&instrument->pHeader->Locale)); + TRACE(" - ulBank: %d\n", instrument->header.Locale.ulBank); + TRACE(" - ulInstrument: %d\n", instrument->header.Locale.ulInstrument); + TRACE(" => dwPatch: %d\n", MIDILOCALE2Patch(&instrument->header.Locale)); } list_add_tail(&This->Instruments, &new_instrument->entry); } diff --git a/dlls/dmusic/dmusic_private.h b/dlls/dmusic/dmusic_private.h index a37a1c3c66..3e5c6c2505 100644 --- a/dlls/dmusic/dmusic_private.h +++ b/dlls/dmusic/dmusic_private.h @@ -238,8 +238,8 @@ struct IDirectMusicInstrumentImpl { /* IDirectMusicInstrumentImpl fields */ LARGE_INTEGER liInstrumentPosition; /* offset in a stream where instrument chunk can be found */ ULONG length; /* Length of the instrument in the stream */ - LPGUID pInstrumentID; - LPINSTHEADER pHeader; + GUID id; + INSTHEADER header; WCHAR wszName[DMUS_MAX_NAME]; /* instrument data */ BOOL loaded; diff --git a/dlls/dmusic/instrument.c b/dlls/dmusic/instrument.c index 13d0c2fda0..d6de0db9f4 100644 --- a/dlls/dmusic/instrument.c +++ b/dlls/dmusic/instrument.c @@ -92,7 +92,7 @@ static HRESULT WINAPI IDirectMusicInstrumentImpl_GetPatch(LPDIRECTMUSICINSTRUMEN TRACE("(%p)->(%p)\n", This, pdwPatch); - *pdwPatch = MIDILOCALE2Patch(&This->pHeader->Locale); + *pdwPatch = MIDILOCALE2Patch(&This->header.Locale); return S_OK; } @@ -103,7 +103,7 @@ static HRESULT WINAPI IDirectMusicInstrumentImpl_SetPatch(LPDIRECTMUSICINSTRUMEN TRACE("(%p)->(%d): stub\n", This, dwPatch); - Patch2MIDILOCALE(dwPatch, &This->pHeader->Locale); + Patch2MIDILOCALE(dwPatch, &This->header.Locale); return S_OK; } @@ -264,7 +264,7 @@ HRESULT IDirectMusicInstrumentImpl_CustomLoad(IDirectMusicInstrument *iface, ISt return DMUS_E_UNSUPPORTED_STREAM; } - This->regions = HeapAlloc(GetProcessHeap(), 0, sizeof(*This->regions) * This->pHeader->cRegions); + This->regions = HeapAlloc(GetProcessHeap(), 0, sizeof(*This->regions) * This->header.cRegions); if (!This->regions) return E_OUTOFMEMORY;