Commit 8c331e33 authored by Andrew Nguyen's avatar Andrew Nguyen Committed by Alexandre Julliard

dxdiagn: Convert the property linked list to a standard Wine list.

parent a421adf0
...@@ -184,7 +184,7 @@ static HRESULT WINAPI IDxDiagContainerImpl_GetNumberOfProps(PDXDIAGCONTAINER ifa ...@@ -184,7 +184,7 @@ static HRESULT WINAPI IDxDiagContainerImpl_GetNumberOfProps(PDXDIAGCONTAINER ifa
static HRESULT WINAPI IDxDiagContainerImpl_EnumPropNames(PDXDIAGCONTAINER iface, DWORD dwIndex, LPWSTR pwszPropName, DWORD cchPropName) { static HRESULT WINAPI IDxDiagContainerImpl_EnumPropNames(PDXDIAGCONTAINER iface, DWORD dwIndex, LPWSTR pwszPropName, DWORD cchPropName) {
IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface; IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface;
IDxDiagContainerImpl_Property* p = NULL; IDxDiagContainerImpl_Property *p;
DWORD i = 0; DWORD i = 0;
TRACE("(%p, %u, %p, %u)\n", iface, dwIndex, pwszPropName, cchPropName); TRACE("(%p, %u, %p, %u)\n", iface, dwIndex, pwszPropName, cchPropName);
...@@ -193,24 +193,24 @@ static HRESULT WINAPI IDxDiagContainerImpl_EnumPropNames(PDXDIAGCONTAINER iface, ...@@ -193,24 +193,24 @@ static HRESULT WINAPI IDxDiagContainerImpl_EnumPropNames(PDXDIAGCONTAINER iface,
return E_INVALIDARG; return E_INVALIDARG;
} }
p = This->properties; LIST_FOR_EACH_ENTRY(p, &This->properties, IDxDiagContainerImpl_Property, entry)
while (NULL != p) { {
if (dwIndex == i) { if (dwIndex == i) {
TRACE("Found property name %s, copying string\n", debugstr_w(p->vName)); TRACE("Found property name %s, copying string\n", debugstr_w(p->propName));
lstrcpynW(pwszPropName, p->vName, cchPropName); lstrcpynW(pwszPropName, p->propName, cchPropName);
return (cchPropName <= strlenW(p->vName)) ? return (cchPropName <= strlenW(p->propName)) ?
DXDIAG_E_INSUFFICIENT_BUFFER : S_OK; DXDIAG_E_INSUFFICIENT_BUFFER : S_OK;
} }
p = p->next;
++i; ++i;
} }
TRACE("Failed to find property name at specified index\n"); TRACE("Failed to find property name at specified index\n");
return E_INVALIDARG; return E_INVALIDARG;
} }
static HRESULT WINAPI IDxDiagContainerImpl_GetProp(PDXDIAGCONTAINER iface, LPCWSTR pwszPropName, VARIANT* pvarProp) { static HRESULT WINAPI IDxDiagContainerImpl_GetProp(PDXDIAGCONTAINER iface, LPCWSTR pwszPropName, VARIANT* pvarProp) {
IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface; IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface;
IDxDiagContainerImpl_Property* p = NULL; IDxDiagContainerImpl_Property *p;
TRACE("(%p, %s, %p)\n", iface, debugstr_w(pwszPropName), pvarProp); TRACE("(%p, %s, %p)\n", iface, debugstr_w(pwszPropName), pvarProp);
...@@ -218,24 +218,23 @@ static HRESULT WINAPI IDxDiagContainerImpl_GetProp(PDXDIAGCONTAINER iface, LPCWS ...@@ -218,24 +218,23 @@ static HRESULT WINAPI IDxDiagContainerImpl_GetProp(PDXDIAGCONTAINER iface, LPCWS
return E_INVALIDARG; return E_INVALIDARG;
} }
p = This->properties; LIST_FOR_EACH_ENTRY(p, &This->properties, IDxDiagContainerImpl_Property, entry)
while (NULL != p) { {
if (0 == lstrcmpW(p->vName, pwszPropName)) { if (0 == lstrcmpW(p->propName, pwszPropName)) {
HRESULT hr = VariantClear(pvarProp); HRESULT hr = VariantClear(pvarProp);
if (hr == DISP_E_ARRAYISLOCKED || hr == DISP_E_BADVARTYPE) if (hr == DISP_E_ARRAYISLOCKED || hr == DISP_E_BADVARTYPE)
VariantInit(pvarProp); VariantInit(pvarProp);
return VariantCopy(pvarProp, &p->v); return VariantCopy(pvarProp, &p->vProp);
} }
p = p->next;
} }
return E_INVALIDARG; return E_INVALIDARG;
} }
HRESULT WINAPI IDxDiagContainerImpl_AddProp(PDXDIAGCONTAINER iface, LPCWSTR pwszPropName, VARIANT* pVarProp) { HRESULT WINAPI IDxDiagContainerImpl_AddProp(PDXDIAGCONTAINER iface, LPCWSTR pwszPropName, VARIANT* pVarProp) {
IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface; IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface;
IDxDiagContainerImpl_Property* p = NULL; IDxDiagContainerImpl_Property *pNew;
IDxDiagContainerImpl_Property* pNew = NULL;
TRACE("(%p, %s, %p)\n", iface, debugstr_w(pwszPropName), pVarProp); TRACE("(%p, %s, %p)\n", iface, debugstr_w(pwszPropName), pVarProp);
...@@ -247,25 +246,17 @@ HRESULT WINAPI IDxDiagContainerImpl_AddProp(PDXDIAGCONTAINER iface, LPCWSTR pwsz ...@@ -247,25 +246,17 @@ HRESULT WINAPI IDxDiagContainerImpl_AddProp(PDXDIAGCONTAINER iface, LPCWSTR pwsz
if (NULL == pNew) { if (NULL == pNew) {
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
VariantInit(&pNew->v);
VariantCopy(&pNew->v, pVarProp); pNew->propName = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(pwszPropName) + 1) * sizeof(WCHAR));
pNew->vName = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(pwszPropName) + 1) * sizeof(WCHAR)); if (NULL == pNew->propName) {
if (NULL == pNew->vName) {
HeapFree(GetProcessHeap(), 0, pNew); HeapFree(GetProcessHeap(), 0, pNew);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
lstrcpyW(pNew->vName, pwszPropName); lstrcpyW(pNew->propName, pwszPropName);
pNew->next = NULL; VariantInit(&pNew->vProp);
VariantCopy(&pNew->vProp, pVarProp);
p = This->properties;
if (NULL == p) { list_add_tail(&This->properties, &pNew->entry);
This->properties = pNew;
} else {
while (NULL != p->next) {
p = p->next;
}
p->next = pNew;
}
++This->nProperties; ++This->nProperties;
return S_OK; return S_OK;
} }
...@@ -324,6 +315,7 @@ HRESULT DXDiag_CreateDXDiagContainer(REFIID riid, LPVOID *ppobj) { ...@@ -324,6 +315,7 @@ HRESULT DXDiag_CreateDXDiagContainer(REFIID riid, LPVOID *ppobj) {
} }
container->lpVtbl = &DxDiagContainer_Vtbl; container->lpVtbl = &DxDiagContainer_Vtbl;
container->ref = 0; /* will be inited with QueryInterface */ container->ref = 0; /* will be inited with QueryInterface */
list_init(&container->properties);
list_init(&container->subContainers); list_init(&container->subContainers);
return IDxDiagContainerImpl_QueryInterface((PDXDIAGCONTAINER)container, riid, ppobj); return IDxDiagContainerImpl_QueryInterface((PDXDIAGCONTAINER)container, riid, ppobj);
} }
...@@ -62,9 +62,9 @@ typedef struct IDxDiagContainerImpl_SubContainer { ...@@ -62,9 +62,9 @@ typedef struct IDxDiagContainerImpl_SubContainer {
} IDxDiagContainerImpl_SubContainer; } IDxDiagContainerImpl_SubContainer;
typedef struct IDxDiagContainerImpl_Property { typedef struct IDxDiagContainerImpl_Property {
LPWSTR vName; struct list entry;
VARIANT v; WCHAR *propName;
struct IDxDiagContainerImpl_Property* next; VARIANT vProp;
} IDxDiagContainerImpl_Property; } IDxDiagContainerImpl_Property;
...@@ -76,7 +76,7 @@ struct IDxDiagContainerImpl { ...@@ -76,7 +76,7 @@ struct IDxDiagContainerImpl {
const IDxDiagContainerVtbl *lpVtbl; const IDxDiagContainerVtbl *lpVtbl;
LONG ref; LONG ref;
/* IDxDiagContainer fields */ /* IDxDiagContainer fields */
IDxDiagContainerImpl_Property* properties; struct list properties;
struct list subContainers; struct list subContainers;
DWORD nProperties; DWORD nProperties;
DWORD nSubContainers; DWORD nSubContainers;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment