d3drm: Use existing helper to manage child frames array.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2017-07-10 13:40:46 +03:00 committed by Alexandre Julliard
parent 6f22d67077
commit b3903a1377
2 changed files with 8 additions and 27 deletions

View File

@ -65,8 +65,8 @@ struct d3drm_frame
IDirect3DRM *d3drm;
LONG ref;
struct d3drm_frame *parent;
ULONG nb_children;
ULONG children_capacity;
SIZE_T nb_children;
SIZE_T children_size;
IDirect3DRMFrame3 **children;
ULONG nb_visuals;
ULONG visuals_capacity;

View File

@ -807,7 +807,7 @@ static HRESULT WINAPI d3drm_frame1_GetClassName(IDirect3DRMFrame *iface, DWORD *
static HRESULT WINAPI d3drm_frame3_AddChild(IDirect3DRMFrame3 *iface, IDirect3DRMFrame3 *child)
{
struct d3drm_frame *This = impl_from_IDirect3DRMFrame3(iface);
struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
struct d3drm_frame *child_obj = unsafe_impl_from_IDirect3DRMFrame3(child);
TRACE("iface %p, child %p.\n", iface, child);
@ -831,32 +831,13 @@ static HRESULT WINAPI d3drm_frame3_AddChild(IDirect3DRMFrame3 *iface, IDirect3DR
}
}
if ((This->nb_children + 1) > This->children_capacity)
{
ULONG new_capacity;
IDirect3DRMFrame3** children;
if (!d3drm_array_reserve((void **)&frame->children, &frame->children_size,
frame->nb_children + 1, sizeof(*frame->children)))
return E_OUTOFMEMORY;
if (!This->children_capacity)
{
new_capacity = 16;
children = HeapAlloc(GetProcessHeap(), 0, new_capacity * sizeof(IDirect3DRMFrame3*));
}
else
{
new_capacity = This->children_capacity * 2;
children = HeapReAlloc(GetProcessHeap(), 0, This->children, new_capacity * sizeof(IDirect3DRMFrame3*));
}
if (!children)
return E_OUTOFMEMORY;
This->children_capacity = new_capacity;
This->children = children;
}
This->children[This->nb_children++] = child;
frame->children[frame->nb_children++] = child;
IDirect3DRMFrame3_AddRef(child);
child_obj->parent = This;
child_obj->parent = frame;
return D3DRM_OK;
}