Module: wine Branch: master Commit: 0bdc248cfe292590de87817d40efe4f5931e1499 URL: https://gitlab.winehq.org/wine/wine/-/commit/0bdc248cfe292590de87817d40efe4f...
Author: Rémi Bernon rbernon@codeweavers.com Date: Fri Sep 15 11:14:08 2023 +0200
dmime: Rewrite segment IDirectMusicSegment_RemoveTrack.
---
dlls/dmime/segment.c | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-)
diff --git a/dlls/dmime/segment.c b/dlls/dmime/segment.c index a1126fe3d5f..8b5f12243d9 100644 --- a/dlls/dmime/segment.c +++ b/dlls/dmime/segment.c @@ -285,29 +285,24 @@ static HRESULT WINAPI segment_InsertTrack(IDirectMusicSegment8 *iface, IDirectMu return segment_append_track(This, track, group, 0); }
-static HRESULT WINAPI segment_RemoveTrack(IDirectMusicSegment8 *iface, IDirectMusicTrack *pTrack) +static HRESULT WINAPI segment_RemoveTrack(IDirectMusicSegment8 *iface, IDirectMusicTrack *track) { - struct segment *This = impl_from_IDirectMusicSegment8(iface); - struct list* pEntry = NULL; - struct track_entry *pIt = NULL; - - TRACE("(%p, %p)\n", This, pTrack); - - LIST_FOR_EACH (pEntry, &This->tracks) { - pIt = LIST_ENTRY(pEntry, struct track_entry, entry); - if (pIt->pTrack == pTrack) { - TRACE("(%p, %p): track in list\n", This, pTrack); - - list_remove(&pIt->entry); - IDirectMusicTrack_Init(pIt->pTrack, NULL); - IDirectMusicTrack_Release(pIt->pTrack); - free(pIt); - - return S_OK; + struct segment *This = impl_from_IDirectMusicSegment8(iface); + struct track_entry *entry; + + TRACE("(%p, %p)\n", This, track); + + LIST_FOR_EACH_ENTRY(entry, &This->tracks, struct track_entry, entry) + { + if (entry->pTrack == track) + { + list_remove(&entry->entry); + track_entry_destroy(entry); + return S_OK; + } } - } - - return S_FALSE; + + return S_FALSE; }
static HRESULT WINAPI segment_InitPlay(IDirectMusicSegment8 *iface,