Some ReAlloc fixes

Dimitrie O. Paun dimi at intelliware.ca
Fri Oct 10 16:37:20 CDT 2003


ChangeLog
    Dimitrie O. Paun <dpaun at rogers.com>
    Fix some instances of memory allocation through HeapReAlloc().


Index: dlls/dmusic/dmusic.c
===================================================================
RCS file: /var/cvs/wine/dlls/dmusic/dmusic.c,v
retrieving revision 1.12
diff -u -r1.12 dmusic.c
--- dlls/dmusic/dmusic.c	5 Sep 2003 23:08:39 -0000	1.12
+++ dlls/dmusic/dmusic.c	10 Oct 2003 21:31:35 -0000
@@ -133,7 +133,8 @@
 	TRACE("(%p, %s, %p, %p, %p)\n", This, debugstr_guid(rclsidPort), pPortParams, ppPort, pUnkOuter);
 	for (i = 0; S_FALSE != IDirectMusic8Impl_EnumPort(iface, i, &PortCaps); i++) {				
 		if (IsEqualCLSID (rclsidPort, &PortCaps.guidPort)) {		
-			This->ppPorts = HeapReAlloc(GetProcessHeap(), 0, This->ppPorts, sizeof(LPDIRECTMUSICPORT) * This->nrofports);
+			if(!This->ppPorts) This->ppPorts = HeapAlloc(GetProcessHeap(), 0, sizeof(LPDIRECTMUSICPORT) * This->nrofports);
+			else This->ppPorts = HeapReAlloc(GetProcessHeap(), 0, This->ppPorts, sizeof(LPDIRECTMUSICPORT) * This->nrofports);
 			if (NULL == This->ppPorts[This->nrofports]) {
 				*ppPort = (LPDIRECTMUSICPORT)NULL;
 				return E_OUTOFMEMORY;
Index: programs/winedbg/hash.c
===================================================================
RCS file: /var/cvs/wine/programs/winedbg/hash.c,v
retrieving revision 1.12
diff -u -r1.12 hash.c
--- programs/winedbg/hash.c	9 Oct 2003 04:39:01 -0000	1.12
+++ programs/winedbg/hash.c	10 Oct 2003 21:16:32 -0000
@@ -1339,7 +1339,9 @@
             {
                 if (num_used_array == num_alloc_array)
                 {
-                    array = HeapReAlloc(GetProcessHeap(), 0, array, sizeof(*array) * (num_alloc_array += 32));
+		    int size = sizeof(*array) * (num_alloc_array += 32);
+		    if (!array) array = HeapAlloc(GetProcessHeap(), 0, size);
+                    else array = HeapReAlloc(GetProcessHeap(), 0, array, size);
                     if (!array) return;
                 }
                 array[num_used_array++] = nh;
Index: programs/winhelp/macro.c
===================================================================
RCS file: /var/cvs/wine/programs/winhelp/macro.c,v
retrieving revision 1.17
diff -u -r1.17 macro.c
--- programs/winhelp/macro.c	1 Oct 2003 03:04:14 -0000	1.17
+++ programs/winhelp/macro.c	10 Oct 2003 21:18:41 -0000
@@ -832,6 +832,7 @@
 {
     HANDLE      hLib;
     void        (*fn)();
+    int         size;
 
     WINE_TRACE("(\"%s\", \"%s\", \"%s\")\n", dll, proc, args);
 
@@ -849,9 +850,9 @@
     }
 
     /* FIXME: the library will not be unloaded until exit of program */
-
-    MACRO_Loaded = HeapReAlloc(GetProcessHeap(), 0, MACRO_Loaded, 
-                               ++MACRO_NumLoaded * sizeof(struct MacroDesc));
+    size = ++MACRO_NumLoaded * sizeof(struct MacroDesc);
+    if (!MACRO_Loaded) MACRO_Loaded = HeapAlloc(GetProcessHeap(), 0, size);
+    else MACRO_Loaded = HeapReAlloc(GetProcessHeap(), 0, MACRO_Loaded, size);
     MACRO_Loaded[MACRO_NumLoaded - 1].name      = strdup(proc); /* FIXME */
     MACRO_Loaded[MACRO_NumLoaded - 1].alias     = NULL;
     MACRO_Loaded[MACRO_NumLoaded - 1].isBool    = 0;

-- 
Dimi.




More information about the wine-patches mailing list