vbscript: Fix memory leak in owned safearray iterator.
[wine.git] / dlls / comsvcs / property.c
blob7a47135769e40b979341750ea49b40d1686a2bb9
1 /*
2 * Copyright 2021 Jactry Zeng for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include "comsvcs_private.h"
20 #include "wine/debug.h"
22 WINE_DEFAULT_DEBUG_CHANNEL(comsvcs);
24 struct group_manager
26 ISharedPropertyGroupManager ISharedPropertyGroupManager_iface;
27 LONG refcount;
30 static struct group_manager *group_manager = NULL;
32 static inline struct group_manager *impl_from_ISharedPropertyGroupManager(ISharedPropertyGroupManager *iface)
34 return CONTAINING_RECORD(iface, struct group_manager, ISharedPropertyGroupManager_iface);
37 static HRESULT WINAPI group_manager_QueryInterface(ISharedPropertyGroupManager *iface, REFIID riid, void **out)
39 struct group_manager *manager = impl_from_ISharedPropertyGroupManager(iface);
41 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
43 if (IsEqualGUID(riid, &IID_IUnknown)
44 || IsEqualGUID(riid, &IID_IDispatch)
45 || IsEqualGUID(riid, &IID_ISharedPropertyGroupManager))
47 *out = &manager->ISharedPropertyGroupManager_iface;
48 IUnknown_AddRef((IUnknown *)*out);
49 return S_OK;
52 WARN("%s not implemented.\n", debugstr_guid(riid));
53 *out = NULL;
54 return E_NOINTERFACE;
57 static ULONG WINAPI group_manager_AddRef(ISharedPropertyGroupManager *iface)
59 struct group_manager *manager = impl_from_ISharedPropertyGroupManager(iface);
60 ULONG refcount = InterlockedIncrement(&manager->refcount);
62 TRACE("%p increasing refcount to %lu.\n", iface, refcount);
64 return refcount;
67 static ULONG WINAPI group_manager_Release(ISharedPropertyGroupManager *iface)
69 struct group_manager *manager = impl_from_ISharedPropertyGroupManager(iface);
70 ULONG refcount = InterlockedDecrement(&manager->refcount);
72 TRACE("%p decreasing refcount to %lu.\n", iface, refcount);
74 return refcount;
77 static HRESULT WINAPI group_manager_GetTypeInfoCount(ISharedPropertyGroupManager *iface, UINT *info)
79 FIXME("iface %p, info %p: stub.\n", iface, info);
80 return E_NOTIMPL;
83 static HRESULT WINAPI group_manager_GetTypeInfo(ISharedPropertyGroupManager *iface, UINT index, LCID lcid,
84 ITypeInfo **info)
86 FIXME("iface %p, index %u, lcid %lu, info %p: stub.\n", iface, index, lcid, info);
87 return E_NOTIMPL;
90 static HRESULT WINAPI group_manager_GetIDsOfNames(ISharedPropertyGroupManager *iface, REFIID riid,
91 LPOLESTR *names, UINT count, LCID lcid, DISPID *dispid)
93 FIXME("iface %p, riid %s, names %p, count %u, lcid %lu, dispid %p: stub.\n",
94 iface, debugstr_guid(riid), names, count, lcid, dispid);
96 return E_NOTIMPL;
99 static HRESULT WINAPI group_manager_Invoke(ISharedPropertyGroupManager *iface, DISPID member, REFIID riid,
100 LCID lcid, WORD flags, DISPPARAMS *params, VARIANT *result, EXCEPINFO *except, UINT *argerr)
102 FIXME("iface %p, member %lu, riid %s, lcid %lu, flags %x, params %p, result %p, except %p, argerr %p: stub.\n",
103 iface, member, debugstr_guid(riid), lcid, flags, params, result, except, argerr);
104 return E_NOTIMPL;
107 static HRESULT WINAPI group_manager_CreatePropertyGroup(ISharedPropertyGroupManager *iface, BSTR name,
108 LONG *isolation, LONG *release, VARIANT_BOOL *exists, ISharedPropertyGroup **group)
110 FIXME("iface %p, name %s, isolation %p, release %p, exists %p, group %p: stub.\n",
111 iface, debugstr_w(name), isolation, release, exists, group);
112 return E_NOTIMPL;
115 static HRESULT WINAPI group_manager_get_Group(ISharedPropertyGroupManager *iface, BSTR name,
116 ISharedPropertyGroup **group)
118 FIXME("iface %p, name %s, group %p: stub.\n", iface, debugstr_w(name), group);
119 return E_NOTIMPL;
122 static HRESULT WINAPI group_manager_get__NewEnum(ISharedPropertyGroupManager *iface, IUnknown **retval)
124 FIXME("iface %p, retval %p: stub.\n", iface, retval);
125 return E_NOTIMPL;
128 static const ISharedPropertyGroupManagerVtbl group_manager_vtbl =
130 group_manager_QueryInterface,
131 group_manager_AddRef,
132 group_manager_Release,
133 group_manager_GetTypeInfoCount,
134 group_manager_GetTypeInfo,
135 group_manager_GetIDsOfNames,
136 group_manager_Invoke,
137 group_manager_CreatePropertyGroup,
138 group_manager_get_Group,
139 group_manager_get__NewEnum
142 HRESULT WINAPI group_manager_create(IClassFactory *iface, IUnknown *outer, REFIID riid, void **out)
144 struct group_manager *manager;
146 if (outer)
147 return CLASS_E_NOAGGREGATION;
149 if (!group_manager)
151 manager = malloc(sizeof(*manager));
152 if (!manager)
154 *out = NULL;
155 return E_OUTOFMEMORY;
157 manager->ISharedPropertyGroupManager_iface.lpVtbl = &group_manager_vtbl;
158 manager->refcount = 1;
160 if (InterlockedCompareExchangePointer((void **)&group_manager, manager, NULL))
162 free(manager);
165 return ISharedPropertyGroupManager_QueryInterface(&group_manager->ISharedPropertyGroupManager_iface, riid, out);