gdi32: Cast-qual warnings fix (1 of 3)

Andrew Talbot Andrew.Talbot at talbotville.com
Mon Oct 30 15:04:25 CST 2006


I also cleaned out some extraneous spaces and incidentally changed the order
in which some of the dynamic memory is freed.

If rejecting this patch, please tell me why on wine-devel.

Thanks,

-- Andy.
---
Changelog:
    gdi32: Cast-qual warning fix.

diff -urN a/dlls/gdi32/font.c b/dlls/gdi32/font.c
--- a/dlls/gdi32/font.c	2006-10-20 14:01:36.000000000 +0100
+++ b/dlls/gdi32/font.c	2006-10-30 20:12:31.000000000 +0000
@@ -1743,7 +1743,7 @@
                          const RECT *lprect, LPCWSTR str, UINT count, const INT *lpDx )
 {
     BOOL ret = FALSE;
-    LPWSTR reordered_str = (LPWSTR)str;
+    LPWSTR reordered_str = NULL;
     WORD *glyphs = NULL;
     UINT align = GetTextAlign( hdc );
     POINT pt;
@@ -1779,16 +1779,17 @@
 
     if (!lprect)
         flags &= ~ETO_CLIPPED;
-        
+
+    reordered_str = HeapAlloc(GetProcessHeap(), 0, count * sizeof(WCHAR));
+    lstrcpynW(reordered_str, str, count);
+
     if( !(flags & (ETO_GLYPH_INDEX | ETO_IGNORELANGUAGE)) && BidiAvail && count > 0 )
     {
-        reordered_str = HeapAlloc(GetProcessHeap(), 0, count*sizeof(WCHAR));
-
         BIDI_Reorder( str, count, GCP_REORDER,
                       ((flags&ETO_RTLREADING)!=0 || (GetTextAlign(hdc)&TA_RTLREADING)!=0)?
                       WINE_GCPW_FORCE_RTL:WINE_GCPW_FORCE_LTR,
                       reordered_str, count, NULL );
-    
+
         flags |= ETO_IGNORELANGUAGE;
     }
 
@@ -1890,7 +1891,7 @@
 
                 deltas[i] = tmpsz.cx;
             }
-            
+
             if (!(flags & ETO_GLYPH_INDEX) && dc->breakExtra && reordered_str[i] == tm.tmBreakChar)
             {
                 deltas[i] = deltas[i] + dc->breakExtra;
@@ -2062,11 +2063,10 @@
     }
 
 done:
-    HeapFree(GetProcessHeap(), 0, deltas);
-    if(glyphs != reordered_str)
+    if (glyphs != reordered_str)
         HeapFree(GetProcessHeap(), 0, glyphs);
-    if(reordered_str != str)
-        HeapFree(GetProcessHeap(), 0, reordered_str);
+    HeapFree(GetProcessHeap(), 0, deltas);
+    HeapFree(GetProcessHeap(), 0, reordered_str);
 
     GDI_ReleaseObj( hdc );
 



More information about the wine-patches mailing list