From a82b1bcfe5087dc04b5b65ed0fa0cebf9a134302 Mon Sep 17 00:00:00 2001 From: Huw Davies Date: Tue, 8 Feb 2005 14:27:52 +0000 Subject: [PATCH] Check if we've already added the ptr to iface typedesc before adding a new one. --- tools/widl/write_msft.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/tools/widl/write_msft.c b/tools/widl/write_msft.c index 1ea502d93ef..f1f77817f50 100644 --- a/tools/widl/write_msft.c +++ b/tools/widl/write_msft.c @@ -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: