mciavi: fix a HeapReAlloc()

Eric Pouech pouech-eric at wanadoo.fr
Fri Nov 21 14:19:53 CST 2003


Dimitrie O. Paun wrote:
> Eric,
> I am fairly certain this is needed, but would you mind
> checking that it's not redundant?
as the code is written it's not needed (but the code is not 
satisfactory). This patch should be better (based on your patch, just 
added some fixes to the first allocation).

A+



-- 
Eric Pouech
-------------- next part --------------
Name:          avi
ChangeLog:     HeapReAlloc doesn't allocate mem
License:       LGPL
GenDate:       2003/11/21 20:19:17 UTC
ModifiedFiles: dlls/winmm/mciavi/mmoutput.c
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/dlls/winmm/mciavi/mmoutput.c,v
retrieving revision 1.5
diff -u -u -r1.5 mmoutput.c
--- dlls/winmm/mciavi/mmoutput.c	19 Oct 2002 17:20:03 -0000	1.5
+++ dlls/winmm/mciavi/mmoutput.c	21 Nov 2003 20:16:45 -0000
@@ -194,9 +194,12 @@
 	if (wma->lpWaveFormat) {
 	    if (alb->numAudioBlocks >= alb->numAudioAllocated) {
 		alb->numAudioAllocated += 32;
-		wma->lpAudioIndex = HeapReAlloc(GetProcessHeap(), 0,
-						wma->lpAudioIndex,
-						alb->numAudioAllocated * sizeof(struct MMIOPos));
+		if (!wma->lpAudioIndex)
+		    wma->lpAudioIndex = HeapAlloc(GetProcessHeap(), 0,
+						  alb->numAudioAllocated * sizeof(struct MMIOPos));
+		else
+		    wma->lpAudioIndex = HeapReAlloc(GetProcessHeap(), 0, wma->lpAudioIndex,
+						    alb->numAudioAllocated * sizeof(struct MMIOPos));
 		if (!wma->lpAudioIndex) return FALSE;
 	    }
 	    wma->lpAudioIndex[alb->numAudioBlocks].dwOffset = mmck->dwDataOffset;
@@ -298,12 +301,7 @@
 	return FALSE;
     }
     wma->dwPlayableAudioBlocks = 0;
-    wma->lpAudioIndex = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
-				  wma->dwPlayableVideoFrames * sizeof(struct MMIOPos));
-    if (!wma->lpAudioIndex) {
-	WARN("Can't alloc audio index array\n");
-	return FALSE;
-    }
+    wma->lpAudioIndex = NULL;
 
     alb.numAudioBlocks = alb.numVideoFrames = 0;
     alb.inVideoSize = alb.inAudioSize = 0;
@@ -484,6 +482,8 @@
 
 void MCIAVI_PlayAudioBlocks(WINE_MCIAVI* wma, unsigned nHdr, LPWAVEHDR waveHdr)
 {
+    if (!wma->lpAudioIndex) 
+        return;
     TRACE("%ld (ec=%lu)\n", wma->lpAudioIndex[wma->dwCurrAudioBlock].dwOffset, wma->dwEventCount);
 
     /* push as many blocks as possible => audio gets priority */


More information about the wine-patches mailing list