Comctl32 memory management

Dimitrie O. Paun dpaun at rogers.com
Fri Mar 25 10:41:22 CST 2005


ChangeLog
    Use {Alloc,ReAlloc,Free}() instead of Heap{Alloc,ReAlloc,Free}().


Index: dlls/comctl32/animate.c
===================================================================
RCS file: /var/cvs/wine/dlls/comctl32/animate.c,v
retrieving revision 1.66
diff -u -r1.66 animate.c
--- dlls/comctl32/animate.c	21 Mar 2005 11:27:49 -0000	1.66
+++ dlls/comctl32/animate.c	25 Mar 2005 16:29:01 -0000
@@ -190,19 +190,19 @@
  	    FreeResource(infoPtr->hRes);
 	    infoPtr->hRes = 0;
 	}
-        HeapFree(GetProcessHeap(), 0, infoPtr->lpIndex);
+        Free (infoPtr->lpIndex);
         infoPtr->lpIndex = NULL;
 	if (infoPtr->hic) {
 	    fnIC.fnICClose(infoPtr->hic);
 	    infoPtr->hic = 0;
 	}
-        HeapFree(GetProcessHeap(), 0, infoPtr->inbih);
+        Free (infoPtr->inbih);
         infoPtr->inbih = NULL;
-        HeapFree(GetProcessHeap(), 0, infoPtr->outbih);
+        Free (infoPtr->outbih);
         infoPtr->outbih = NULL;
-	HeapFree(GetProcessHeap(), 0, infoPtr->indata);
+	Free (infoPtr->indata);
         infoPtr->indata = NULL;
-	HeapFree(GetProcessHeap(), 0, infoPtr->outdata);
+	Free (infoPtr->outdata);
         infoPtr->outdata = NULL;
     	if( infoPtr->hbmPrevFrame )
         {
@@ -557,7 +557,7 @@
 	return FALSE;
     }
 
-    infoPtr->inbih = HeapAlloc(GetProcessHeap(), 0, mmckInfo.cksize);
+    infoPtr->inbih = Alloc(mmckInfo.cksize);
     if (!infoPtr->inbih) {
 	WARN("Can't alloc input BIH\n");
 	return FALSE;
@@ -604,8 +604,7 @@
 
     /* FIXME: should handle the 'rec ' LIST when present */
 
-    infoPtr->lpIndex = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
-				 infoPtr->mah.dwTotalFrames * sizeof(DWORD));
+    infoPtr->lpIndex = Alloc(infoPtr->mah.dwTotalFrames * sizeof(DWORD));
     if (!infoPtr->lpIndex) 
 	return FALSE;
 
@@ -627,7 +626,7 @@
 	infoPtr->ash.dwSuggestedBufferSize = insize;
     }
 
-    infoPtr->indata = HeapAlloc(GetProcessHeap(), 0, infoPtr->ash.dwSuggestedBufferSize);
+    infoPtr->indata = Alloc(infoPtr->ash.dwSuggestedBufferSize);
     if (!infoPtr->indata) 
 	return FALSE;
 
@@ -658,7 +657,7 @@
     outSize = fnIC.fnICSendMessage(infoPtr->hic, ICM_DECOMPRESS_GET_FORMAT,
 			    (DWORD)infoPtr->inbih, 0L);
 
-    infoPtr->outbih = HeapAlloc(GetProcessHeap(), 0, outSize);
+    infoPtr->outbih = Alloc(outSize);
     if (!infoPtr->outbih)
 	return FALSE;
 
@@ -669,7 +668,7 @@
 	return FALSE;
     }
 
-    infoPtr->outdata = HeapAlloc(GetProcessHeap(), 0, infoPtr->outbih->biSizeImage);
+    infoPtr->outdata = Alloc(infoPtr->outbih->biSizeImage);
     if (!infoPtr->outdata) 
 	return FALSE;
 
@@ -757,12 +756,12 @@
         return ANIMATE_OpenW(infoPtr, hInstance, (LPWSTR)lpszName);
 
     len = MultiByteToWideChar(CP_ACP, 0, lpszName, -1, NULL, 0);
-    lpwszName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
+    lpwszName = Alloc(len * sizeof(WCHAR));
     if (!lpwszName) return FALSE;
     MultiByteToWideChar(CP_ACP, 0, lpszName, -1, lpwszName, len);
 
     result = ANIMATE_OpenW(infoPtr, hInstance, lpwszName);
-    HeapFree(GetProcessHeap(), 0, lpwszName);
+    Free (lpwszName);
     return result;
 }
 
Index: dlls/comctl32/commctrl.c
===================================================================
RCS file: /var/cvs/wine/dlls/comctl32/commctrl.c,v
retrieving revision 1.92
diff -u -r1.92 commctrl.c
--- dlls/comctl32/commctrl.c	23 Mar 2005 10:22:37 -0000	1.92
+++ dlls/comctl32/commctrl.c	25 Mar 2005 16:29:01 -0000
@@ -514,12 +514,12 @@
 
     if ( text ) {
 	if ( (len = MultiByteToWideChar( CP_ACP, 0, text, -1, NULL, 0 )) ) {
-	    if ( (textW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )) )
+	    if ( (textW = Alloc( len * sizeof(WCHAR) )) )
 		MultiByteToWideChar( CP_ACP, 0, text, -1, textW, len );
 	}
     }
     DrawStatusTextW( hdc, lprc, textW, style );
-    HeapFree( GetProcessHeap(), 0, textW );
+    Free( textW );
 }
 
 
@@ -1107,7 +1107,7 @@
    stack = (LPSUBCLASS_INFO)GetPropW (hWnd, COMCTL32_wSubclass);
    if (!stack) {
       /* allocate stack */
-      stack = HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(SUBCLASS_INFO));
+      stack = Alloc (sizeof(SUBCLASS_INFO));
       if (!stack) {
          ERR ("Failed to allocate our Subclassing stack\n");
          return FALSE;
@@ -1136,14 +1136,14 @@
       }
    }
    
-   proc = HeapAlloc(GetProcessHeap(), 0, sizeof(SUBCLASSPROCS));
+   proc = Alloc(sizeof(SUBCLASSPROCS));
    if (!proc) {
       ERR ("Failed to allocate subclass entry in stack\n");
       if (IsWindowUnicode (hWnd))
          SetWindowLongPtrW (hWnd, GWLP_WNDPROC, (DWORD_PTR)stack->origproc);
       else
          SetWindowLongPtrA (hWnd, GWLP_WNDPROC, (DWORD_PTR)stack->origproc);
-      HeapFree (GetProcessHeap (), 0, stack);
+      Free (stack);
       RemovePropW( hWnd, COMCTL32_wSubclass );
       return FALSE;
    }
@@ -1243,7 +1243,7 @@
          if (stack->stackpos == proc)
             stack->stackpos = stack->stackpos->next;
             
-         HeapFree (GetProcessHeap (), 0, proc);
+         Free (proc);
          ret = TRUE;
          break;
       }
@@ -1258,7 +1258,7 @@
          SetWindowLongPtrW (hWnd, GWLP_WNDPROC, (DWORD_PTR)stack->origproc);
       else
          SetWindowLongPtrA (hWnd, GWLP_WNDPROC, (DWORD_PTR)stack->origproc);
-      HeapFree (GetProcessHeap (), 0, stack);
+      Free (stack);
       RemovePropW( hWnd, COMCTL32_wSubclass );
    }
    
@@ -1300,7 +1300,7 @@
          SetWindowLongPtrW (hWnd, GWLP_WNDPROC, (DWORD_PTR)stack->origproc);
       else
          SetWindowLongPtrA (hWnd, GWLP_WNDPROC, (DWORD_PTR)stack->origproc);
-      HeapFree (GetProcessHeap (), 0, stack);
+      Free (stack);
       RemovePropW( hWnd, COMCTL32_wSubclass );
    }
    return ret;
Index: dlls/comctl32/imagelist.c
===================================================================
RCS file: /var/cvs/wine/dlls/comctl32/imagelist.c,v
retrieving revision 1.96
diff -u -r1.96 imagelist.c
--- dlls/comctl32/imagelist.c	24 Mar 2005 15:07:40 -0000	1.96
+++ dlls/comctl32/imagelist.c	25 Mar 2005 16:29:01 -0000
@@ -1598,11 +1598,11 @@
                                     uType, uFlags);
 
     len = MultiByteToWideChar(CP_ACP, 0, lpbmp, -1, NULL, 0);
-    lpbmpW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
+    lpbmpW = Alloc(len * sizeof(WCHAR));
     MultiByteToWideChar(CP_ACP, 0, lpbmp, -1, lpbmpW, len);
 
     himl = ImageList_LoadImageW(hi, lpbmpW, cx, cGrow, clrMask, uType, uFlags);
-    HeapFree(GetProcessHeap(), 0, lpbmpW);
+    Free (lpbmpW);
     return himl;
 }
 
@@ -2790,7 +2790,7 @@
 	    BYTE temp;
 
 	    colors = 1 << himl->uBitsPixel;
-	    bmi = HeapAlloc(GetProcessHeap(), 0, sizeof(BITMAPINFOHEADER) +
+	    bmi = Alloc(sizeof(BITMAPINFOHEADER) +
 	                    sizeof(PALETTEENTRY) * colors);
 
 	    pal = (LPPALETTEENTRY)bmi->bmiColors;
@@ -2807,7 +2807,7 @@
 	}
 	else
 	{
-	    bmi = HeapAlloc(GetProcessHeap(), 0, sizeof(BITMAPINFOHEADER));
+	    bmi = Alloc(sizeof(BITMAPINFOHEADER));
 	}
 
 	bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
@@ -2824,7 +2824,7 @@
 
 	hbmNewBitmap = CreateDIBSection(hdc, bmi, DIB_RGB_COLORS, &bits, 0, 0);
 
-	HeapFree(GetProcessHeap(), 0, bmi);
+	Free (bmi);
     }
     else /*if (ilc == ILC_COLORDDB)*/
     {
Index: dlls/comctl32/listview.c
===================================================================
RCS file: /var/cvs/wine/dlls/comctl32/listview.c,v
retrieving revision 1.405
diff -u -r1.405 listview.c
--- dlls/comctl32/listview.c	23 Mar 2005 13:15:21 -0000	1.405
+++ dlls/comctl32/listview.c	25 Mar 2005 16:36:52 -0000
@@ -440,7 +440,7 @@
     if (!isW && is_textT(text, isW))
     {
 	INT len = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)text, -1, NULL, 0);
-	wstr = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
+	wstr = Alloc(len * sizeof(WCHAR));
 	if (wstr) MultiByteToWideChar(CP_ACP, 0, (LPCSTR)text, -1, wstr, len);
     }
     TRACE("   wstr=%s\n", text == LPSTR_TEXTCALLBACKW ?  "(callback)" : debugstr_w(wstr));
@@ -449,7 +449,7 @@
 
 static inline void textfreeT(LPWSTR wstr, BOOL isW)
 {
-    if (!isW && is_textT(wstr, isW)) HeapFree(GetProcessHeap(), 0, wstr);
+    if (!isW && is_textT(wstr, isW)) Free (wstr);
 }
 
 /*
@@ -852,8 +852,7 @@
  	    *pdi->item.pszText = 0; /* make sure we don't process garbage */
  	}
 
-	pszTempBuf = HeapAlloc(GetProcessHeap(), 0,
-	    (convertToUnicode ? sizeof(WCHAR) : sizeof(CHAR)) * cchTempBufMax);
+	pszTempBuf = Alloc( (convertToUnicode ? sizeof(WCHAR) : sizeof(CHAR)) * cchTempBufMax);
         if (!pszTempBuf) return FALSE;
 
 	if (convertToUnicode)
@@ -886,7 +885,7 @@
 	                        savPszText, savCchTextMax);
         pdi->item.pszText = savPszText; /* restores our buffer */
         pdi->item.cchTextMax = savCchTextMax;
-        HeapFree(GetProcessHeap(), 0, pszTempBuf);
+        Free (pszTempBuf);
     }
     return bResult;
 }
Index: dlls/comctl32/propsheet.c
===================================================================
RCS file: /var/cvs/wine/dlls/comctl32/propsheet.c,v
retrieving revision 1.125
diff -u -r1.125 propsheet.c
--- dlls/comctl32/propsheet.c	25 Mar 2005 10:26:10 -0000	1.125
+++ dlls/comctl32/propsheet.c	25 Mar 2005 16:34:18 -0000
@@ -323,7 +323,7 @@
 
     TRACE("<%s>\n", frstr);
     len = MultiByteToWideChar(CP_ACP, 0, frstr, -1, 0, 0);
-    *tostr = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
+    *tostr = Alloc(len * sizeof(WCHAR));
     MultiByteToWideChar(CP_ACP, 0, frstr, -1, (LPWSTR)*tostr, len);
 }
 
@@ -357,7 +357,7 @@
      if (HIWORD(lppsh->pszCaption))
      {
         int len = MultiByteToWideChar(CP_ACP, 0, lppsh->pszCaption, -1, NULL, 0);
-        psInfo->ppshheader.pszCaption = HeapAlloc( GetProcessHeap(), 0, len*sizeof (WCHAR) );
+        psInfo->ppshheader.pszCaption = Alloc( len*sizeof (WCHAR) );
         MultiByteToWideChar(CP_ACP, 0, lppsh->pszCaption, -1, (LPWSTR) psInfo->ppshheader.pszCaption, len);
      }
   }
@@ -411,7 +411,7 @@
      if (HIWORD(lppsh->pszCaption))
      {
         int len = strlenW(lppsh->pszCaption);
-        psInfo->ppshheader.pszCaption = HeapAlloc( GetProcessHeap(), 0, (len+1)*sizeof(WCHAR) );
+        psInfo->ppshheader.pszCaption = Alloc( (len+1)*sizeof(WCHAR) );
         strcpyW( (WCHAR *)psInfo->ppshheader.pszCaption, lppsh->pszCaption );
      }
   }
@@ -2422,7 +2422,7 @@
      PROPSHEETPAGEW* psp = (PROPSHEETPAGEW*)psInfo->proppage[index].hpage;
 
      if ((psp->dwFlags & PSP_USETITLE) && psInfo->proppage[index].pszText)
-        HeapFree(GetProcessHeap(), 0, (LPVOID)psInfo->proppage[index].pszText);
+        Free ((LPVOID)psInfo->proppage[index].pszText);
 
      DestroyPropertySheetPage(psInfo->proppage[index].hpage);
   }
@@ -2693,7 +2693,7 @@
   TRACE("\n");
   if (!psInfo) return;
   if (HIWORD(psInfo->ppshheader.pszCaption))
-      HeapFree(GetProcessHeap(), 0, (LPVOID)psInfo->ppshheader.pszCaption);
+      Free ((LPVOID)psInfo->ppshheader.pszCaption);
 
   for (i = 0; i < psInfo->nPages; i++)
   {
@@ -2714,7 +2714,7 @@
      if(psp)
      {
         if ((psp->dwFlags & PSP_USETITLE) && psInfo->proppage[i].pszText)
-           HeapFree(GetProcessHeap(), 0, (LPVOID)psInfo->proppage[i].pszText);
+           Free ((LPVOID)psInfo->proppage[i].pszText);
 
         DestroyPropertySheetPage(psInfo->proppage[i].hpage);
      }
@@ -2865,7 +2865,7 @@
   {
      int len = strlen(lpPropSheetPage->u.pszTemplate);
 
-     ppsp->u.pszTemplate = HeapAlloc( GetProcessHeap(),0,len+1 );
+     ppsp->u.pszTemplate = Alloc( len+1 );
      strcpy( (LPSTR)ppsp->u.pszTemplate, lpPropSheetPage->u.pszTemplate );
   }
   if ( (ppsp->dwFlags & PSP_USEICONID) && HIWORD( ppsp->u2.pszIcon ) )
@@ -2900,20 +2900,20 @@
   {
     int len = strlenW(lpPropSheetPage->u.pszTemplate);
 
-    ppsp->u.pszTemplate = HeapAlloc( GetProcessHeap(),0,(len+1)*sizeof (WCHAR) );
+    ppsp->u.pszTemplate = Alloc( (len+1)*sizeof (WCHAR) );
     strcpyW( (WCHAR *)ppsp->u.pszTemplate, lpPropSheetPage->u.pszTemplate );
   }
   if ( (ppsp->dwFlags & PSP_USEICONID) && HIWORD( ppsp->u2.pszIcon ) )
   {
       int len = strlenW(lpPropSheetPage->u2.pszIcon);
-      ppsp->u2.pszIcon = HeapAlloc( GetProcessHeap(), 0, (len+1)*sizeof (WCHAR) );
+      ppsp->u2.pszIcon = Alloc( (len+1)*sizeof (WCHAR) );
       strcpyW( (WCHAR *)ppsp->u2.pszIcon, lpPropSheetPage->u2.pszIcon );
   }
 
   if ((ppsp->dwFlags & PSP_USETITLE) && HIWORD( ppsp->pszTitle ))
   {
       int len = strlenW(lpPropSheetPage->pszTitle);
-      ppsp->pszTitle = HeapAlloc( GetProcessHeap(), 0, (len+1)*sizeof (WCHAR) );
+      ppsp->pszTitle = Alloc( (len+1)*sizeof (WCHAR) );
       strcpyW( (WCHAR *)ppsp->pszTitle, lpPropSheetPage->pszTitle );
   }
   else if ( !(ppsp->dwFlags & PSP_USETITLE) )
@@ -2941,13 +2941,13 @@
      return FALSE;
 
   if ( !(psp->dwFlags & PSP_DLGINDIRECT) && HIWORD( psp->u.pszTemplate ) )
-     HeapFree(GetProcessHeap(), 0, (LPVOID)psp->u.pszTemplate);
+     Free ((LPVOID)psp->u.pszTemplate);
 
   if ( (psp->dwFlags & PSP_USEICONID) && HIWORD( psp->u2.pszIcon ) )
-     HeapFree(GetProcessHeap(), 0, (LPVOID)psp->u2.pszIcon);
+     Free ((LPVOID)psp->u2.pszIcon);
 
   if ((psp->dwFlags & PSP_USETITLE) && HIWORD( psp->pszTitle ))
-     HeapFree(GetProcessHeap(), 0, (LPVOID)psp->pszTitle);
+     Free ((LPVOID)psp->pszTitle);
 
   Free(hPropPage);
 
Index: dlls/comctl32/syslink.c
===================================================================
RCS file: /var/cvs/wine/dlls/comctl32/syslink.c,v
retrieving revision 1.10
diff -u -r1.10 syslink.c
--- dlls/comctl32/syslink.c	25 Mar 2005 10:26:10 -0000	1.10
+++ dlls/comctl32/syslink.c	25 Mar 2005 16:29:01 -0000
@@ -33,6 +33,7 @@
 #include "winuser.h"
 #include "winnls.h"
 #include "commctrl.h"
+#include "comctl32.h"
 #include "wine/unicode.h"
 #include "wine/debug.h"
 
@@ -40,10 +41,6 @@
 
 INT WINAPI StrCmpNIW(LPCWSTR,LPCWSTR,INT);
 
-#define SYSLINK_Alloc(size)        HeapAlloc(GetProcessHeap(), 0, (size))
-#define SYSLINK_Free(ptr)          HeapFree(GetProcessHeap(), 0, (ptr))
-#define SYSLINK_ReAlloc(ptr, size) HeapReAlloc(GetProcessHeap(), 0, ptr, (size))
-
 typedef struct
 {
     int nChars;
@@ -115,8 +112,8 @@
 {
     if(DocItem->Type == slLink)
     {
-        SYSLINK_Free(DocItem->u.Link.szID);
-        SYSLINK_Free(DocItem->u.Link.szUrl);
+        Free(DocItem->u.Link.szID);
+        Free(DocItem->u.Link.szUrl);
     }
 
     if(DocItem->Type == slLink && DocItem->u.Link.hRgn != NULL)
@@ -127,7 +124,7 @@
     /* we don't free Text because it's just a pointer to a character in the
        entire window text string */
 
-    SYSLINK_Free(DocItem);
+    Free(DocItem);
 }
 
 /***********************************************************************
@@ -138,7 +135,7 @@
                                         SL_ITEM_TYPE type, PDOC_ITEM LastItem)
 {
     PDOC_ITEM Item;
-    Item = SYSLINK_Alloc(sizeof(DOC_ITEM) + ((textlen + 1) * sizeof(WCHAR)));
+    Item = Alloc(sizeof(DOC_ITEM) + ((textlen + 1) * sizeof(WCHAR)));
     if(Item == NULL)
     {
         ERR("Failed to alloc DOC_ITEM structure!\n");
@@ -371,7 +368,7 @@
                         {
                             nc = min(lenId, strlenW(lpID));
                             nc = min(nc, MAX_LINKID_TEXT);
-                            Last->u.Link.szID = SYSLINK_Alloc((MAX_LINKID_TEXT + 1) * sizeof(WCHAR));
+                            Last->u.Link.szID = Alloc((MAX_LINKID_TEXT + 1) * sizeof(WCHAR));
                             if(Last->u.Link.szID != NULL)
                             {
                                 lstrcpynW(Last->u.Link.szID, lpID, nc + 1);
@@ -384,7 +381,7 @@
                         {
                             nc = min(lenUrl, strlenW(lpUrl));
                             nc = min(nc, L_MAX_URL_LENGTH);
-                            Last->u.Link.szUrl = SYSLINK_Alloc((L_MAX_URL_LENGTH + 1) * sizeof(WCHAR));
+                            Last->u.Link.szUrl = Alloc((L_MAX_URL_LENGTH + 1) * sizeof(WCHAR));
                             if(Last->u.Link.szUrl != NULL)
                             {
                                 lstrcpynW(Last->u.Link.szUrl, lpUrl, nc + 1);
@@ -451,7 +448,7 @@
             {
                 nc = min(lenId, strlenW(lpID));
                 nc = min(nc, MAX_LINKID_TEXT);
-                Last->u.Link.szID = SYSLINK_Alloc((MAX_LINKID_TEXT + 1) * sizeof(WCHAR));
+                Last->u.Link.szID = Alloc((MAX_LINKID_TEXT + 1) * sizeof(WCHAR));
                 if(Last->u.Link.szID != NULL)
                 {
                     lstrcpynW(Last->u.Link.szID, lpID, nc + 1);
@@ -464,7 +461,7 @@
             {
                 nc = min(lenUrl, strlenW(lpUrl));
                 nc = min(nc, L_MAX_URL_LENGTH);
-                Last->u.Link.szUrl = SYSLINK_Alloc((L_MAX_URL_LENGTH + 1) * sizeof(WCHAR));
+                Last->u.Link.szUrl = Alloc((L_MAX_URL_LENGTH + 1) * sizeof(WCHAR));
                 if(Last->u.Link.szUrl != NULL)
                 {
                     lstrcpynW(Last->u.Link.szUrl, lpUrl, nc + 1);
@@ -737,11 +734,11 @@
                 
                 if(bl != NULL)
                 {
-                    bl = SYSLINK_ReAlloc(bl, ++nBlocks * sizeof(DOC_TEXTBLOCK));
+                    bl = ReAlloc(bl, ++nBlocks * sizeof(DOC_TEXTBLOCK));
                 }
                 else
                 {
-                    bl = SYSLINK_Alloc(++nBlocks * sizeof(DOC_TEXTBLOCK));
+                    bl = Alloc(++nBlocks * sizeof(DOC_TEXTBLOCK));
                 }
                 
                 if(bl != NULL)
@@ -1039,7 +1036,7 @@
     {
         if(!di->u.Link.szID)
         {
-            di->u.Link.szID = SYSLINK_Alloc((MAX_LINKID_TEXT + 1) * sizeof(WCHAR));
+            di->u.Link.szID = Alloc((MAX_LINKID_TEXT + 1) * sizeof(WCHAR));
             if(!Item->szID)
             {
                 ERR("Unable to allocate memory for link id\n");
@@ -1056,7 +1053,7 @@
     {
         if(!di->u.Link.szUrl)
         {
-            di->u.Link.szUrl = SYSLINK_Alloc((MAX_LINKID_TEXT + 1) * sizeof(WCHAR));
+            di->u.Link.szUrl = Alloc((MAX_LINKID_TEXT + 1) * sizeof(WCHAR));
             if(!Item->szUrl)
             {
                 ERR("Unable to allocate memory for link url\n");
@@ -1609,7 +1606,7 @@
 
     case WM_CREATE:
         /* allocate memory for info struct */
-        infoPtr = (SYSLINK_INFO *)SYSLINK_Alloc (sizeof(SYSLINK_INFO));
+        infoPtr = Alloc (sizeof(SYSLINK_INFO));
         if (!infoPtr) return -1;
         SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr);
 
@@ -1633,8 +1630,8 @@
         SYSLINK_ClearDoc(infoPtr);
         if(infoPtr->Font != 0) DeleteObject(infoPtr->Font);
         if(infoPtr->LinkFont != 0) DeleteObject(infoPtr->LinkFont);
-        SYSLINK_Free (infoPtr);
         SetWindowLongPtrW(hwnd, 0, 0);
+        Free (infoPtr);
         return 0;
 
     default:
Index: dlls/comctl32/toolbar.c
===================================================================
RCS file: /var/cvs/wine/dlls/comctl32/toolbar.c,v
retrieving revision 1.210
diff -u -r1.210 toolbar.c
--- dlls/comctl32/toolbar.c	25 Mar 2005 10:27:00 -0000	1.210
+++ dlls/comctl32/toolbar.c	25 Mar 2005 16:29:01 -0000
@@ -4430,7 +4430,7 @@
         res = ERROR_FILE_NOT_FOUND;
     if (!res)
     {
-        nmtbr.pData = HeapAlloc(GetProcessHeap(), 0, dwSize);
+        nmtbr.pData = Alloc(dwSize);
         nmtbr.cbData = (UINT)dwSize;
         if (!nmtbr.pData) res = ERROR_OUTOFMEMORY;
     }
@@ -4503,7 +4503,7 @@
             if (infoPtr->nNumButtons > 0) ret = TRUE;
         }
     }
-    HeapFree(GetProcessHeap(), 0, nmtbr.pData);
+    Free (nmtbr.pData);
     RegCloseKey(hkey);
 
     return ret;
@@ -4535,12 +4535,12 @@
     if (lpSave == NULL) return 0;
 
     len = MultiByteToWideChar(CP_ACP, 0, lpSave->pszSubKey, -1, NULL, 0);
-    pszSubKey = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
+    pszSubKey = Alloc(len * sizeof(WCHAR));
     if (pszSubKey) goto exit;
     MultiByteToWideChar(CP_ACP, 0, lpSave->pszSubKey, -1, pszSubKey, len);
 
     len = MultiByteToWideChar(CP_ACP, 0, lpSave->pszValueName, -1, NULL, 0);
-    pszValueName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
+    pszValueName = Alloc(len * sizeof(WCHAR));
     if (!pszValueName) goto exit;
     MultiByteToWideChar(CP_ACP, 0, lpSave->pszValueName, -1, pszValueName, len);
 
@@ -4550,8 +4550,8 @@
     result = TOOLBAR_SaveRestoreW(hwnd, wParam, &SaveW);
 
 exit:
-    HeapFree(GetProcessHeap(), 0, pszValueName);
-    HeapFree(GetProcessHeap(), 0, pszSubKey);
+    Free (pszValueName);
+    Free (pszSubKey);
 
     return result;
 }
@@ -5534,7 +5534,7 @@
 	DestroyWindow (infoPtr->hwndToolTip);
 
     /* delete temporary buffer for tooltip text */
-    HeapFree(GetProcessHeap(), 0, infoPtr->pszTooltipText);
+    Free (infoPtr->pszTooltipText);
 
     /* delete button data */
     if (infoPtr->buttons)
@@ -6288,7 +6288,7 @@
 
     TRACE("button index = %d\n", index);
 
-    HeapFree(GetProcessHeap(), 0, infoPtr->pszTooltipText);
+    Free (infoPtr->pszTooltipText);
     infoPtr->pszTooltipText = NULL;
 
     if (index < 0)
@@ -6318,7 +6318,7 @@
             /* need to allocate temporary buffer in infoPtr as there
              * isn't enough space in buffer passed to us by the
              * tooltip control */
-            infoPtr->pszTooltipText = HeapAlloc(GetProcessHeap(), 0, (len+1)*sizeof(WCHAR));
+            infoPtr->pszTooltipText = Alloc((len+1)*sizeof(WCHAR));
             if (infoPtr->pszTooltipText)
             {
                 memcpy(infoPtr->pszTooltipText, tbgit.pszText, (len+1)*sizeof(WCHAR));
@@ -6356,7 +6356,7 @@
             /* need to allocate temporary buffer in infoPtr as there
              * isn't enough space in buffer passed to us by the
              * tooltip control */
-            infoPtr->pszTooltipText = HeapAlloc(GetProcessHeap(), 0, (len+1)*sizeof(WCHAR));
+            infoPtr->pszTooltipText = Alloc((len+1)*sizeof(WCHAR));
             if (infoPtr->pszTooltipText)
             {
                 MultiByteToWideChar(CP_ACP, 0, tbgit.pszText, len+1, infoPtr->pszTooltipText, (len+1)*sizeof(WCHAR));
@@ -6386,7 +6386,7 @@
             /* need to allocate temporary buffer in infoPtr as there
              * isn't enough space in buffer passed to us by the
              * tooltip control */
-            infoPtr->pszTooltipText = HeapAlloc(GetProcessHeap(), 0, (len+1)*sizeof(WCHAR));
+            infoPtr->pszTooltipText = Alloc((len+1)*sizeof(WCHAR));
             if (infoPtr->pszTooltipText)
             {
                 memcpy(infoPtr->pszTooltipText, pszText, (len+1)*sizeof(WCHAR));

-- 
Dimi.



More information about the wine-patches mailing list