From db15ce658035ca018abc418f11c88d124ea7531c Mon Sep 17 00:00:00 2001 From: Michael Stefaniuc Date: Wed, 8 Jun 2011 17:29:20 +0200 Subject: [PATCH] ddraw: Rename d3d_material_init() and have it allocate the object too. --- dlls/ddraw/ddraw.c | 4 +--- dlls/ddraw/ddraw_private.h | 2 +- dlls/ddraw/material.c | 10 +++++++++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c index 51e8c8c4ddc..d3ee86140dd 100644 --- a/dlls/ddraw/ddraw.c +++ b/dlls/ddraw/ddraw.c @@ -4603,15 +4603,13 @@ static HRESULT WINAPI d3d3_CreateMaterial(IDirect3D3 *iface, IDirect3DMaterial3 if (outer_unknown) return CLASS_E_NOAGGREGATION; - object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); + object = d3d_material_create(This); if (!object) { ERR("Failed to allocate material memory.\n"); return DDERR_OUTOFMEMORY; } - d3d_material_init(object, This); - TRACE("Created material %p.\n", object); *material = (IDirect3DMaterial3 *)object; diff --git a/dlls/ddraw/ddraw_private.h b/dlls/ddraw/ddraw_private.h index cce8574df86..0da8f557fc7 100644 --- a/dlls/ddraw/ddraw_private.h +++ b/dlls/ddraw/ddraw_private.h @@ -429,7 +429,7 @@ struct IDirect3DMaterialImpl /* Helper functions */ void material_activate(IDirect3DMaterialImpl* This) DECLSPEC_HIDDEN; -void d3d_material_init(IDirect3DMaterialImpl *material, IDirectDrawImpl *ddraw) DECLSPEC_HIDDEN; +IDirect3DMaterialImpl *d3d_material_create(IDirectDrawImpl *ddraw) DECLSPEC_HIDDEN; /***************************************************************************** * IDirect3DViewport - Wraps to D3D7 diff --git a/dlls/ddraw/material.c b/dlls/ddraw/material.c index 10ce3400dd2..42e48099fca 100644 --- a/dlls/ddraw/material.c +++ b/dlls/ddraw/material.c @@ -507,11 +507,19 @@ static const struct IDirect3DMaterialVtbl d3d_material1_vtbl = IDirect3DMaterialImpl_Unreserve }; -void d3d_material_init(IDirect3DMaterialImpl *material, IDirectDrawImpl *ddraw) +IDirect3DMaterialImpl *d3d_material_create(IDirectDrawImpl *ddraw) { + IDirect3DMaterialImpl *material; + + material = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*material)); + if (!material) + return NULL; + material->lpVtbl = &d3d_material3_vtbl; material->IDirect3DMaterial2_iface.lpVtbl = &d3d_material2_vtbl; material->IDirect3DMaterial_iface.lpVtbl = &d3d_material1_vtbl; material->ref = 1; material->ddraw = ddraw; + + return material; }