Andrew Eikum : oleaut32: Overwrite previous CustData segment.

Alexandre Julliard julliard at winehq.org
Thu Aug 19 11:44:02 CDT 2010


Module: wine
Branch: master
Commit: a8dbeb1e60098d78c6875e7dcb023d5c97c27d60
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=a8dbeb1e60098d78c6875e7dcb023d5c97c27d60

Author: Andrew Eikum <aeikum at codeweavers.com>
Date:   Wed Aug 18 12:21:22 2010 -0500

oleaut32: Overwrite previous CustData segment.

This eliminates the diff between Wine's and Windows XP's generated TLB
files.

---

 dlls/oleaut32/typelib2.c |   36 ++++++++++++++++++++++++++++++++----
 1 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/dlls/oleaut32/typelib2.c b/dlls/oleaut32/typelib2.c
index b2c086b..cc8c7a2 100644
--- a/dlls/oleaut32/typelib2.c
+++ b/dlls/oleaut32/typelib2.c
@@ -921,6 +921,26 @@ static HRESULT ctl2_encode_variant(
     }
 }
 
+static int ctl2_find_custdata(
+    ICreateTypeLib2Impl *This,
+    REFGUID guid,
+    int offset)
+{
+    while (offset != -1) {
+        MSFT_CDGuid *cdentry =
+            (MSFT_CDGuid *)&This->typelib_segment_data[MSFT_SEG_CUSTDATAGUID][offset];
+        MSFT_GuidEntry *guidentry =
+            (MSFT_GuidEntry *)&This->typelib_segment_data[MSFT_SEG_GUID][cdentry->GuidOffset];
+
+        if (IsEqualGUID(guidentry, guid))
+            return offset;
+
+        offset = cdentry->next;
+    }
+
+    return -1;
+}
+
 /****************************************************************************
  *	ctl2_set_custdata
  *
@@ -943,6 +963,7 @@ static HRESULT ctl2_set_custdata(
     int guidoffset;
     int custoffset;
     int *custdata;
+    BOOL new_segment = FALSE;
 
     switch(V_VT(pVarVal))
     {
@@ -971,14 +992,21 @@ static HRESULT ctl2_set_custdata(
     if (status)
 	return status;
 
-    custoffset = ctl2_alloc_segment(This, MSFT_SEG_CUSTDATAGUID, 12, 0);
-    if (custoffset == -1) return E_OUTOFMEMORY;
+    custoffset = ctl2_find_custdata(This, guid, *offset);
+    if (custoffset == -1) {
+        custoffset = ctl2_alloc_segment(This, MSFT_SEG_CUSTDATAGUID, 12, 0);
+        if (custoffset == -1)
+            return E_OUTOFMEMORY;
+        new_segment = TRUE;
+    }
 
     custdata = (int *)&This->typelib_segment_data[MSFT_SEG_CUSTDATAGUID][custoffset];
     custdata[0] = guidoffset;
     custdata[1] = dataoffset;
-    custdata[2] = *offset;
-    *offset = custoffset;
+    if (new_segment) {
+        custdata[2] = *offset;
+        *offset = custoffset;
+    }
 
     return S_OK;
 }




More information about the wine-cvs mailing list