[1/2] msxml3: Store handlers pointers so casts to particular type are avoided
Nikolay Sivov
nsivov at codeweavers.com
Fri Nov 16 07:25:02 CST 2012
Store handlers pointers so casts to particular type are avoided
-------------- next part --------------
>From bec393baa7932a3c7beb8bd1ce4bd140403af6d1 Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <nsivov at codeweavers.com>
Date: Thu, 15 Nov 2012 22:34:58 -0500
Subject: [PATCH 1/2] Store handlers pointers so casts to particular type are
avoided
---
dlls/msxml3/saxreader.c | 28 +++++++++++++++++++---------
1 file changed, 19 insertions(+), 9 deletions(-)
diff --git a/dlls/msxml3/saxreader.c b/dlls/msxml3/saxreader.c
index 9ebdc0f..21c5b4f 100644
--- a/dlls/msxml3/saxreader.c
+++ b/dlls/msxml3/saxreader.c
@@ -173,7 +173,7 @@ enum saxhandler_type
SAXHandler_Last
};
-struct saxhandler_iface
+struct saxanyhandler_iface
{
IUnknown *handler;
IUnknown *vbhandler;
@@ -197,6 +197,16 @@ struct saxlexicalhandler_iface
IVBSAXLexicalHandler *vbhandler;
};
+struct saxhandler_iface
+{
+ union {
+ struct saxcontenthandler_iface content;
+ struct saxerrorhandler_iface error;
+ struct saxlexicalhandler_iface lexical;
+ struct saxanyhandler_iface anyhandler;
+ } u;
+};
+
typedef struct
{
DispatchEx dispex;
@@ -215,7 +225,7 @@ typedef struct
static HRESULT saxreader_put_handler(saxreader *reader, enum saxhandler_type type, void *ptr, BOOL vb)
{
- struct saxhandler_iface *iface = &reader->saxhandlers[type];
+ struct saxanyhandler_iface *iface = &reader->saxhandlers[type].u.anyhandler;
IUnknown *unk = (IUnknown*)ptr;
if (unk)
@@ -234,7 +244,7 @@ static HRESULT saxreader_put_handler(saxreader *reader, enum saxhandler_type typ
static HRESULT saxreader_get_handler(const saxreader *reader, enum saxhandler_type type, BOOL vb, void **ret)
{
- const struct saxhandler_iface *iface = &reader->saxhandlers[type];
+ const struct saxanyhandler_iface *iface = &reader->saxhandlers[type].u.anyhandler;
if (!ret) return E_POINTER;
@@ -253,17 +263,17 @@ static HRESULT saxreader_get_handler(const saxreader *reader, enum saxhandler_ty
static struct saxcontenthandler_iface *saxreader_get_contenthandler(saxreader *reader)
{
- return (struct saxcontenthandler_iface*)&reader->saxhandlers[SAXContentHandler];
+ return &reader->saxhandlers[SAXContentHandler].u.content;
}
static struct saxerrorhandler_iface *saxreader_get_errorhandler(saxreader *reader)
{
- return (struct saxerrorhandler_iface*)&reader->saxhandlers[SAXErrorHandler];
+ return &reader->saxhandlers[SAXErrorHandler].u.error;
}
static struct saxlexicalhandler_iface *saxreader_get_lexicalhandler(saxreader *reader)
{
- return (struct saxlexicalhandler_iface*)&reader->saxhandlers[SAXLexicalHandler];
+ return &reader->saxhandlers[SAXLexicalHandler].u.lexical;
}
typedef struct
@@ -327,8 +337,8 @@ static inline saxlocator *impl_from_ISAXAttributes( ISAXAttributes *iface )
static inline int saxreader_has_handler(const saxlocator *locator, enum saxhandler_type type)
{
- return (locator->vbInterface && locator->saxreader->saxhandlers[type].vbhandler) ||
- (!locator->vbInterface && locator->saxreader->saxhandlers[type].handler);
+ struct saxanyhandler_iface *iface = &locator->saxreader->saxhandlers[type].u.anyhandler;
+ return (locator->vbInterface && iface->vbhandler) || (!locator->vbInterface && iface->handler);
}
/* property names */
@@ -2734,7 +2744,7 @@ static ULONG WINAPI saxxmlreader_Release(
for (i = 0; i < SAXHandler_Last; i++)
{
- struct saxhandler_iface *iface = &This->saxhandlers[i];
+ struct saxanyhandler_iface *iface = &This->saxhandlers[i].u.anyhandler;
if (iface->handler)
IUnknown_Release(iface->handler);
--
1.7.10.4
More information about the wine-patches
mailing list