[hxcommon] cr for QueryInterface size reductions
Henry Ping ping at real.comSince qiList->ilnter can be NULL, i.e.
{ IID_IHXFileSwitcher, (IHXFileSwitcher*) m_pFileSwitcher },
{ IID_IHXCommonClassFactory, m_pClassFactory },
We need to add NULL check after assignment: *ppvObj = qiList->iInter and
return HXR_NOINTERFACE if *ppvObj == NULL.
-->Henry
At 04:43 PM 7/29/2003 -0700, Aaron Colwell wrote:
>Very tricky. I like how you tied the function definition to INITGUID.
>Don't forget to add a *ppvObj = 0; for the case where HXR_NOINTERFACE will
>be returned. I think that most QI implementations do this.
>
>Aaron
>
>On Tue, 29 Jul 2003, Greg Wright wrote:
>
> > This diff adds 1 struct and 1 C function to help in QI size reductions.
> > Diff should be self expanatory.
> >
> >
> > --greg.
> >
> > Index: hxcom.h
> > ===================================================================
> > RCS file: /cvs/common/include/hxcom.h,v
> > retrieving revision 1.14
> > diff -u -w -r1.14 hxcom.h
> > --- hxcom.h 24 Jul 2003 22:43:45 -0000 1.14
> > +++ hxcom.h 29 Jul 2003 23:15:54 -0000
> > @@ -712,6 +712,51 @@
> >
> >
> >
> > +/* QueryInterface size reduction structs and functions.
> > + *
> > + * Used like:
> > + * STDMETHODIMP CQTFileFormat::QueryInterface(REFIID riid, void**
> ppvObj)
> > + * {
> > + * QInterfaceList qiList[] =
> > + * {
> > + * { IID_IUnknown, (IUnknown*) (IHXPlugin*) this },
> > + * { IID_IHXPlugin, (IHXPlugin*) this },
> > + * { IID_IUnknown, NULL }
> > + * };
> > + *
> > + * return QIFind(qiList, riid, ppvObj);
> > + * }
> > + */
> > +typedef struct _QInterfaceList
> > +{
> > + IID riid;
> > + void* iInter;
> > +} QInterfaceList;
> > +
> > +#if defined(INITGUID)
> > +EXTERN_C HX_RESULT QIFind(const QInterfaceList* const qiList, REFIID
> riid, void** ppvObj)
> > +{
> > + while (qiList->iInter)
> > + {
> > + if (qiList->riid == riid)
> > + {
> > + *ppvObj = qiList->iInter;
> > + return HXR_OK;
> > + }
> > + }
> > + return HXR_NOINTERFACE;
> > +}
> > +#else
> > +EXTERN_C HX_RESULT QIFind(const QInterfaceList* const qiList,
> > + REFIID riid,
> > + void** ppvObj);
> > +#endif
> > +
> > +
> > +
> > +
> > +
> > +
> > #if defined(HELIX_CONFIG_COMPACT_COM_MACROS)
> >
> > EXTERN_C void HX_AddRefFunc(IUnknown** pUnk);
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe at common.helixcommunity.org
> > For additional commands, e-mail: dev-help at common.helixcommunity.org
> >
> >
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: dev-unsubscribe at common.helixcommunity.org
>For additional commands, e-mail: dev-help at common.helixcommunity.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe at common.helixcommunity.org
For additional commands, e-mail: dev-help at common.helixcommunity.org