[PATCH 1/5] d3drm: Use existing helper to manage child frames array
Nikolay Sivov
nsivov at codeweavers.com
Mon Jul 10 05:40:46 CDT 2017
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
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 067c0e6ffe..89e641497a 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 0d6ee149fa..ffe75060db 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 (!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;
- }
+ if (!d3drm_array_reserve((void **)&frame->children, &frame->children_size,
+ frame->nb_children + 1, sizeof(*frame->children)))
+ return E_OUTOFMEMORY;
- 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;
}
--
2.13.2
More information about the wine-patches
mailing list