widl #37: iface ptr check

Huw D M Davies h.davies1 at physics.ox.ac.uk
Tue Feb 8 06:39:52 CST 2005


        Huw Davies <huw at codeweavers.com>
        Check if we've already added the ptr to iface typedesc before
        adding a new one.
-- 
Huw Davies
huw at codeweavers.com
Index: tools/widl/write_msft.c
===================================================================
RCS file: /home/wine/wine/tools/widl/write_msft.c,v
retrieving revision 1.30
diff -u -p -r1.30 write_msft.c
--- tools/widl/write_msft.c	8 Feb 2005 12:09:42 -0000	1.30
+++ tools/widl/write_msft.c	8 Feb 2005 12:37:02 -0000
@@ -910,17 +910,23 @@ static int encode_type(
 	*alignment = 1;
 
         if(type->type == RPC_FC_IP) {
-            typeoffset = ctl2_alloc_segment(typelib, MSFT_SEG_TYPEDESC, 8, 0);
-	    typedata = (void *)&typelib->typelib_segment_data[MSFT_SEG_TYPEDESC][typeoffset];
+            for (typeoffset = 0; typeoffset < typelib->typelib_segdir[MSFT_SEG_TYPEDESC].length; typeoffset += 8) {
+                typedata = (void *)&typelib->typelib_segment_data[MSFT_SEG_TYPEDESC][typeoffset];
+                if ((typedata[0] == ((0x7fff << 16) | VT_PTR)) && (typedata[1] == *encoded_type)) break;
+            }
+            if (typeoffset == typelib->typelib_segdir[MSFT_SEG_TYPEDESC].length) {
+                typeoffset = ctl2_alloc_segment(typelib, MSFT_SEG_TYPEDESC, 8, 0);
+                typedata = (void *)&typelib->typelib_segment_data[MSFT_SEG_TYPEDESC][typeoffset];
 
-	    typedata[0] = (0x7fff << 16) | VT_PTR;
-	    typedata[1] = *encoded_type;
+                typedata[0] = (0x7fff << 16) | VT_PTR;
+                typedata[1] = *encoded_type;
+            }
             *encoded_type = typeoffset;
             *width = 4;
             *alignment = 4;
             *decoded_size += 8;
-        }            
-	break;
+        }
+        break;
       }
 
     default:



More information about the wine-patches mailing list