[PATCH 6/6] Get rid of some magic offset values, use structure for that
Nikolay Sivov
nsivov at codeweavers.com
Sun Dec 26 17:43:31 CST 2010
---
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..d8c0178 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, Info), 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 */
--
1.5.6.5
--------------080703080902040500080408--
More information about the wine-patches
mailing list