[1/16] msxml3: Support functions for typelib

Alexandre Julliard julliard at winehq.org
Sat Feb 16 09:01:19 CST 2008


Alistair Leslie-Hughes <leslie_alistair at hotmail.com> writes:

> +HRESULT get_typeinfo(enum tid_t tid, ITypeInfo **typeinfo)
> +{
> +    HRESULT hres;
> +
> +    if(!typelib) {
> +        ITypeLib *tl;
> +
> +        hres = LoadRegTypeLib(&LIBID_MSXML2, 3, 0, LOCALE_SYSTEM_DEFAULT, &tl);
> +        if(FAILED(hres)) {
> +            ERR("LoadRegTypeLib failed: %08x\n", hres);
> +            return hres;
> +        }
> +
> +        if(InterlockedCompareExchangePointer((void**)&typelib, tl, NULL))
> +            ITypeLib_Release(tl);
> +    }
> +
> +    if(!typeinfos[tid]) {
> +        ITypeInfo *typeinfo;
> +
> +        hres = ITypeLib_GetTypeInfoOfGuid(typelib, tid_ids[tid], &typeinfo);
> +        if(FAILED(hres)) {
> +            ERR("GetTypeInfoOfGuid failed: %08x\n", hres);
> +            return hres;
> +        }
> +
> +        if(InterlockedCompareExchangePointer((void**)(typeinfos+tid), typeinfo, NULL))
> +            ITypeInfo_Release(typeinfo);
> +    }
> +
> +    *typeinfo = typeinfos[tid];
> +    return S_OK;

You should increment the ref count when you are returning a pointer,
even if it's also stored in a global variable.

-- 
Alexandre Julliard
julliard at winehq.org



More information about the wine-devel mailing list