Check if we've already added the ptr to iface typedesc before adding a
authorHuw Davies <huw@codeweavers.com>
Tue, 8 Feb 2005 14:27:52 +0000 (14:27 +0000)
committerAlexandre Julliard <julliard@winehq.org>
Tue, 8 Feb 2005 14:27:52 +0000 (14:27 +0000)
new one.

tools/widl/write_msft.c

index 1ea502d93efcbc8296638927d61f1e744e0db398..f1f77817f5077b0b9f760eb3e2dd5bda45eeb986 100644 (file)
@@ -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: