On 8/19/20 10:48 AM, Jactry Zeng wrote:
+static ULONG WINAPI group_manager_Release(ISharedPropertyGroupManager *iface) +{
- struct group_manager *manager = impl_from_ISharedPropertyGroupManager(iface);
- ULONG refcount = InterlockedDecrement(&manager->refcount);
- TRACE("%p decreasing refcount to %u.\n", iface, refcount);
- if (!refcount)
- {
heap_free(manager);
group_manager = NULL;
group_manager->cs.DebugInfo->Spare[0] = 0;
DeleteCriticalSection(&group_manager->cs);
- }
- return refcount;
+}
Does this work?
+HRESULT WINAPI group_manager_create(IClassFactory *iface, IUnknown *outer, REFIID riid, void **out) +{
- HRESULT hr;
- if (outer)
return CLASS_E_NOAGGREGATION;
- if (!group_manager)
- {
group_manager = heap_alloc(sizeof(*group_manager));
if (!group_manager)
{
out = NULL;
return E_OUTOFMEMORY;
}
group_manager->ISharedPropertyGroupManager_iface.lpVtbl = &group_manager_vtbl;
group_manager->refcount = 1;
InitializeCriticalSection(&group_manager->cs);
group_manager->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": ISharedPropertyGroupManager.cs");
- }
- hr = ISharedPropertyGroupManager_QueryInterface(&group_manager->ISharedPropertyGroupManager_iface, riid, out);
- return hr;
+}
What I meant is that it should use pattern similar to what's using for global typelib instance initialization later in your series.
The question also is if you should release it at all, maybe it's not possible, and Release() does nothing but refcount manipulation.