Nikolay Sivov : d3drm: Use existing helper to manage child frames array.
Alexandre Julliard
julliard at winehq.org
Mon Jul 10 15:52:46 CDT 2017
Module: wine
Branch: master
Commit: b3903a13771afe9e22af54bc5867dde7de114530
URL: http://source.winehq.org/git/wine.git/?a=commit;h=b3903a13771afe9e22af54bc5867dde7de114530
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Mon Jul 10 13:40:46 2017 +0300
d3drm: Use existing helper to manage child frames array.
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
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 067c0e6..89e6414 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 0d6ee14..ffe7506 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;
}
More information about the wine-cvs
mailing list