Nikolay Sivov : oleaut32: Get rid of some magic offset values, use structure for that.

Alexandre Julliard julliard at winehq.org
Mon Dec 27 10:03:55 CST 2010


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

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Mon Dec 27 03:43:19 2010 +0300

oleaut32: Get rid of some magic offset values, use structure for that.

---

 dlls/oleaut32/typelib.c |   25 ++++++++++++++-----------
 dlls/oleaut32/typelib.h |    3 +--
 2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/dlls/oleaut32/typelib.c b/dlls/oleaut32/typelib.c
index 36328a6..72e1932 100644
--- a/dlls/oleaut32/typelib.c
+++ b/dlls/oleaut32/typelib.c
@@ -2094,7 +2094,7 @@ static void MSFT_DoVars(TLBContext *pcx, ITypeInfoImpl *pTI, int cFuncs,
 {
     int infolen, nameoffset, reclength;
     char recbuf[256];
-    MSFT_VarRecord * pVarRec=(MSFT_VarRecord *) recbuf;
+    MSFT_VarRecord *pVarRec = (MSFT_VarRecord*)recbuf;
     int i;
     int recoffset;
 
@@ -2111,17 +2111,20 @@ static void MSFT_DoVars(TLBContext *pcx, ITypeInfoImpl *pTI, int cFuncs,
                           offset + infolen + (2*cFuncs + cVars + i + 1) * sizeof(INT));
         (*pptvd)->Name=MSFT_ReadName(pcx, nameoffset);
     /* read the variable information record */
-        MSFT_ReadLEDWords(&reclength, sizeof(INT), pcx, recoffset);
-        reclength &=0xff;
-        MSFT_ReadLEDWords(pVarRec, reclength - sizeof(INT), pcx, DO_NOT_SEEK);
-    /* Optional data */
-        if(reclength >(6*sizeof(INT)) )
-            (*pptvd)->HelpContext=pVarRec->HelpContext;
-        if(reclength >(7*sizeof(INT)) )
+        MSFT_ReadLEDWords(&reclength, sizeof(pVarRec->Info), pcx, recoffset);
+        reclength &= 0xff;
+        MSFT_ReadLEDWords(&pVarRec->DataType, reclength - FIELD_OFFSET(MSFT_VarRecord, DataType), pcx, DO_NOT_SEEK);
+
+        /* optional data */
+        if(reclength > FIELD_OFFSET(MSFT_VarRecord, HelpContext))
+            (*pptvd)->HelpContext = pVarRec->HelpContext;
+
+        if(reclength > FIELD_OFFSET(MSFT_VarRecord, oHelpString))
             (*pptvd)->HelpString = MSFT_ReadString(pcx, pVarRec->oHelpString) ;
-        if(reclength >(8*sizeof(INT)) )
-        if(reclength >(9*sizeof(INT)) )
-            (*pptvd)->HelpStringContext=pVarRec->HelpStringContext;
+
+        if(reclength > FIELD_OFFSET(MSFT_VarRecord, HelpStringContext))
+            (*pptvd)->HelpStringContext = pVarRec->HelpStringContext;
+
     /* fill the VarDesc Structure */
         MSFT_ReadLEDWords(&(*pptvd)->vardesc.memid, sizeof(INT), pcx,
                           offset + infolen + (cFuncs + i + 1) * sizeof(INT));
diff --git a/dlls/oleaut32/typelib.h b/dlls/oleaut32/typelib.h
index 3b5f09b..210db33 100644
--- a/dlls/oleaut32/typelib.h
+++ b/dlls/oleaut32/typelib.h
@@ -231,7 +231,7 @@ typedef struct {
 
 /* Variable description data */
 typedef struct {
-/*  INT   recsize;      // record size including some xtra stuff */
+    INT   Info;         /* record size including some extra stuff */
     INT   DataType;     /* data type of the variable */
     INT   Flags;        /* VarFlags (LOWORD) */
 #ifdef WORDS_BIGENDIAN
@@ -250,7 +250,6 @@ typedef struct {
     INT   res9;         /* unknown (-1) */
     INT   oCustData;        /* custom data for variable */
     INT   HelpStringContext;
-
 } MSFT_VarRecord;
 
 /* Structure of the reference data  */




More information about the wine-cvs mailing list