[3/5] netprofm: Add a class factory implementation.
Dmitry Timoshkov
dmitry.timoshkov at gmail.com
Mon Apr 7 09:32:46 CDT 2014
Hi Hans,
Hans Leidekker <hans at codeweavers.com> wrote:
> +struct netprofm_cf
> +{
> + const struct IClassFactoryVtbl *vtbl;
> + HRESULT (*create_instance)(void **);
> +};
> +
> +static inline struct netprofm_cf *impl_from_IClassFactory( IClassFactory *iface )
> +{
> + return (struct netprofm_cf *)((char *)iface - FIELD_OFFSET( struct netprofm_cf, vtbl ));
> +}
Objects in this new dll don't follow http://wiki.winehq.org/COMGuideline,
but that's not a big problem, and could be fixed later.
> +static HRESULT WINAPI netprofm_cf_CreateInstance( IClassFactory *iface, LPUNKNOWN outer,
> + REFIID riid, LPVOID *obj )
> +{
> + struct netprofm_cf *factory = impl_from_IClassFactory( iface );
> + IUnknown *unk;
> + HRESULT r;
> +
> + TRACE( "%p %s %p\n", outer, debugstr_guid(riid), obj );
> +
> + *obj = NULL;
> + if (outer) return CLASS_E_NOAGGREGATION;
> +
> + r = factory->create_instance( (void **)&unk );
> + if (FAILED( r ))
> + return r;
> +
> + r = IUnknown_QueryInterface( unk, riid, obj );
> + if (FAILED( r ))
> + return r;
> +
> + IUnknown_Release( unk );
> + return r;
> +}
It seems that 'unk' is leaked if IUnknown_QueryInterface fails.
--
Dmitry.
More information about the wine-devel
mailing list