[PATCH 4/5] d3drm: Use existing helper to manage mesh groups

Nikolay Sivov nsivov at codeweavers.com
Mon Jul 10 05:40:49 CDT 2017


Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
 dlls/d3drm/d3drm_private.h |  4 ++--
 dlls/d3drm/meshbuilder.c   | 24 ++----------------------
 2 files changed, 4 insertions(+), 24 deletions(-)

diff --git a/dlls/d3drm/d3drm_private.h b/dlls/d3drm/d3drm_private.h
index 861c3abeb4..65e0016a18 100644
--- a/dlls/d3drm/d3drm_private.h
+++ b/dlls/d3drm/d3drm_private.h
@@ -168,8 +168,8 @@ struct d3drm_mesh
     IDirect3DRMMesh IDirect3DRMMesh_iface;
     LONG ref;
     IDirect3DRM *d3drm;
-    DWORD groups_capacity;
-    DWORD nb_groups;
+    SIZE_T nb_groups;
+    SIZE_T groups_size;
     struct mesh_group *groups;
 };
 
diff --git a/dlls/d3drm/meshbuilder.c b/dlls/d3drm/meshbuilder.c
index bb37678785..c95cb46df1 100644
--- a/dlls/d3drm/meshbuilder.c
+++ b/dlls/d3drm/meshbuilder.c
@@ -2532,28 +2532,8 @@ static HRESULT WINAPI d3drm_mesh_AddGroup(IDirect3DRMMesh *iface, unsigned verte
     if (!face_data || !id)
         return E_POINTER;
 
-    if ((mesh->nb_groups + 1) > mesh->groups_capacity)
-    {
-        struct mesh_group *groups;
-        ULONG new_capacity;
-
-        if (!mesh->groups_capacity)
-        {
-            new_capacity = 16;
-            groups = HeapAlloc(GetProcessHeap(), 0, new_capacity * sizeof(*groups));
-        }
-        else
-        {
-            new_capacity = mesh->groups_capacity * 2;
-            groups = HeapReAlloc(GetProcessHeap(), 0, mesh->groups, new_capacity * sizeof(*groups));
-        }
-
-        if (!groups)
-            return E_OUTOFMEMORY;
-
-        mesh->groups_capacity = new_capacity;
-        mesh->groups = groups;
-    }
+    if (!d3drm_array_reserve((void **)&mesh->groups, &mesh->groups_size, mesh->nb_groups + 1, sizeof(*mesh->groups)))
+        return E_OUTOFMEMORY;
 
     group = mesh->groups + mesh->nb_groups;
 
-- 
2.13.2




More information about the wine-patches mailing list