Nikolay Sivov : opcservices: Keep relationships in a set.
Alexandre Julliard
julliard at winehq.org
Wed Sep 5 16:15:27 CDT 2018
Module: wine
Branch: master
Commit: d28cf66224370191e61249a4ca8ac4301b90842f
URL: https://source.winehq.org/git/wine.git/?a=commit;h=d28cf66224370191e61249a4ca8ac4301b90842f
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Wed Sep 5 08:37:24 2018 +0300
opcservices: Keep relationships in a set.
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/opcservices/package.c | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/dlls/opcservices/package.c b/dlls/opcservices/package.c
index 869fb03..e671685 100644
--- a/dlls/opcservices/package.c
+++ b/dlls/opcservices/package.c
@@ -69,6 +69,10 @@ struct opc_relationship_set
{
IOpcRelationshipSet IOpcRelationshipSet_iface;
LONG refcount;
+
+ struct opc_relationship **relationships;
+ size_t size;
+ size_t count;
};
static inline struct opc_package *impl_from_IOpcPackage(IOpcPackage *iface)
@@ -440,16 +444,22 @@ static const IOpcRelationshipVtbl opc_relationship_vtbl =
opc_relationship_GetTargetMode,
};
-static HRESULT opc_relationship_create(IOpcRelationship **out)
+static HRESULT opc_relationship_create(struct opc_relationship_set *set, IOpcRelationship **out)
{
struct opc_relationship *relationship;
+ if (!opc_array_reserve((void **)&set->relationships, &set->size, set->count + 1, sizeof(*set->relationships)))
+ return E_OUTOFMEMORY;
+
if (!(relationship = heap_alloc_zero(sizeof(*relationship))))
return E_OUTOFMEMORY;
relationship->IOpcRelationship_iface.lpVtbl = &opc_relationship_vtbl;
relationship->refcount = 1;
+ set->relationships[set->count++] = relationship;
+ IOpcRelationship_AddRef(&relationship->IOpcRelationship_iface);
+
*out = &relationship->IOpcRelationship_iface;
TRACE("Created relationship %p.\n", *out);
return S_OK;
@@ -489,7 +499,14 @@ static ULONG WINAPI opc_relationship_set_Release(IOpcRelationshipSet *iface)
TRACE("%p decreasing refcount to %u.\n", iface, refcount);
if (!refcount)
+ {
+ size_t i;
+
+ for (i = 0; i < relationship_set->count; ++i)
+ IOpcRelationship_Release(&relationship_set->relationships[i]->IOpcRelationship_iface);
+ heap_free(relationship_set->relationships);
heap_free(relationship_set);
+ }
return refcount;
}
@@ -505,10 +522,12 @@ static HRESULT WINAPI opc_relationship_set_GetRelationship(IOpcRelationshipSet *
static HRESULT WINAPI opc_relationship_set_CreateRelationship(IOpcRelationshipSet *iface, const WCHAR *id,
const WCHAR *type, IUri *target_uri, OPC_URI_TARGET_MODE target_mode, IOpcRelationship **relationship)
{
+ struct opc_relationship_set *relationship_set = impl_from_IOpcRelationshipSet(iface);
+
FIXME("iface %p, id %s, type %s, target_uri %p, target_mode %d, relationship %p stub!\n", iface, debugstr_w(id),
debugstr_w(type), target_uri, target_mode, relationship);
- return opc_relationship_create(relationship);
+ return opc_relationship_create(relationship_set, relationship);
}
static HRESULT WINAPI opc_relationship_set_DeleteRelationship(IOpcRelationshipSet *iface, const WCHAR *id)
More information about the wine-cvs
mailing list