Alistair Leslie-Hughes leslie_alistair@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@winehq.org wrote in message news:878x1lc5ds.fsf@wine.dyndns.org...
Alistair Leslie-Hughes leslie_alistair@hotmail.com writes:
- *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.
If have corrected this in the next patch, the other 2-16 patches should be disregarded since they increment the typeinfo pointer in each function is called. Ill correct the 2-16 patches shortly.
Best Regards Alistair Leslie-Hughes
"Alexandre Julliard" julliard@winehq.org wrote in message news:878x1lc5ds.fsf@wine.dyndns.org...
- *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.
Hi, After reviewing the changes I need to an AddRef to typeinfo, it doesnt make sense.
In each GetTypeInfo function we do an AddRef since the user gets a pointer pack to the typinfo pointer.
Where as, in GetIDsOfNames and Invoke functions we use the get_typeinfo function to retreive the pointer and in this case we dont want to increment the pointer.
What is the best course of actions? 1. AddRef in get_typeinfo and therefore Release in GetIDsOfNames and Invoke or 2. AddRef in GetTypeInfo, and nothing else has to be changed.
Best Regards Alistair Leslie-Hughes
"Alistair Leslie-Hughes" leslie_alistair@hotmail.com writes:
What is the best course of actions?
- AddRef in get_typeinfo and therefore Release in GetIDsOfNames and Invoke
or 2. AddRef in GetTypeInfo, and nothing else has to be changed.
You have to follow the COM rules, so 1.