From b3903a13771afe9e22af54bc5867dde7de114530 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Mon, 10 Jul 2017 13:40:46 +0300 Subject: [PATCH] d3drm: Use existing helper to manage child frames array. Signed-off-by: Nikolay Sivov Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/d3drm/d3drm_private.h | 4 ++-- dlls/d3drm/frame.c | 31 ++++++------------------------- 2 files changed, 8 insertions(+), 27 deletions(-) diff --git a/dlls/d3drm/d3drm_private.h b/dlls/d3drm/d3drm_private.h index 067c0e6ffeb..89e641497a2 100644 --- a/dlls/d3drm/d3drm_private.h +++ b/dlls/d3drm/d3drm_private.h @@ -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; diff --git a/dlls/d3drm/frame.c b/dlls/d3drm/frame.c index 0d6ee149fa1..ffe75060dbe 100644 --- a/dlls/d3drm/frame.c +++ b/dlls/d3drm/frame.c @@ -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; }