Module: wine Branch: master Commit: 0459a3273d92237787ca9326e1bbc0ec43f5e2cf URL: http://source.winehq.org/git/wine.git/?a=commit;h=0459a3273d92237787ca9326e1...
Author: Nikolay Sivov nsivov@codeweavers.com Date: Mon Jul 10 13:40:47 2017 +0300
d3drm: Use existing helper to manage lights 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
---
dlls/d3drm/d3drm_private.h | 4 ++-- dlls/d3drm/frame.c | 33 +++++++-------------------------- 2 files changed, 9 insertions(+), 28 deletions(-)
diff --git a/dlls/d3drm/d3drm_private.h b/dlls/d3drm/d3drm_private.h index 89e6414..16c1415 100644 --- a/dlls/d3drm/d3drm_private.h +++ b/dlls/d3drm/d3drm_private.h @@ -71,8 +71,8 @@ struct d3drm_frame ULONG nb_visuals; ULONG visuals_capacity; IDirect3DRMVisual **visuals; - ULONG nb_lights; - ULONG lights_capacity; + SIZE_T nb_lights; + SIZE_T lights_size; IDirect3DRMLight **lights; D3DRMMATRIX4D transform; D3DCOLOR scenebackground; diff --git a/dlls/d3drm/frame.c b/dlls/d3drm/frame.c index ffe7506..7d89686 100644 --- a/dlls/d3drm/frame.c +++ b/dlls/d3drm/frame.c @@ -875,9 +875,8 @@ static HRESULT WINAPI d3drm_frame1_AddChild(IDirect3DRMFrame *iface, IDirect3DRM
static HRESULT WINAPI d3drm_frame3_AddLight(IDirect3DRMFrame3 *iface, IDirect3DRMLight *light) { - struct d3drm_frame *This = impl_from_IDirect3DRMFrame3(iface); + struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface); ULONG i; - IDirect3DRMLight** lights;
TRACE("iface %p, light %p.\n", iface, light);
@@ -885,33 +884,15 @@ static HRESULT WINAPI d3drm_frame3_AddLight(IDirect3DRMFrame3 *iface, IDirect3DR return D3DRMERR_BADOBJECT;
/* Check if already existing and return gracefully without increasing ref count */ - for (i = 0; i < This->nb_lights; i++) - if (This->lights[i] == light) + for (i = 0; i < frame->nb_lights; i++) + if (frame->lights[i] == light) return D3DRM_OK;
- if ((This->nb_lights + 1) > This->lights_capacity) - { - ULONG new_capacity; - - if (!This->lights_capacity) - { - new_capacity = 16; - lights = HeapAlloc(GetProcessHeap(), 0, new_capacity * sizeof(IDirect3DRMLight*)); - } - else - { - new_capacity = This->lights_capacity * 2; - lights = HeapReAlloc(GetProcessHeap(), 0, This->lights, new_capacity * sizeof(IDirect3DRMLight*)); - } - - if (!lights) - return E_OUTOFMEMORY; - - This->lights_capacity = new_capacity; - This->lights = lights; - } + if (!d3drm_array_reserve((void **)&frame->lights, &frame->lights_size, + frame->nb_lights + 1, sizeof(*frame->lights))) + return E_OUTOFMEMORY;
- This->lights[This->nb_lights++] = light; + frame->lights[frame->nb_lights++] = light; IDirect3DRMLight_AddRef(light);
return D3DRM_OK;