https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3daf9d55e67b6baaaa08bdac9e9214ba337d89ab

commit 3daf9d55e67b6baaaa08bdac9e9214ba337d89ab
Author:     winesync <[email protected]>
AuthorDate: Mon Sep 21 23:03:21 2020 +0200
Commit:     Jérôme Gardou <[email protected]>
CommitDate: Thu Feb 4 16:37:04 2021 +0100

    [WINESYNC] d3dx9: Factor out free_parameter_object_data() function.
    
    Signed-off-by: Paul Gofman <[email protected]>
    Signed-off-by: Matteo Bruni <[email protected]>
    Signed-off-by: Alexandre Julliard <[email protected]>
    
    wine commit id 07562f1e3927b2aa1521811f0c16a7f05c175cba by Paul Gofman 
<[email protected]>
---
 dll/directx/wine/d3dx9_36/effect.c | 29 +++++++++++++++++++++++------
 sdk/tools/winesync/d3dx9.cfg       |  2 +-
 2 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/dll/directx/wine/d3dx9_36/effect.c 
b/dll/directx/wine/d3dx9_36/effect.c
index e6fc00d3777..3f0c2a5c109 100644
--- a/dll/directx/wine/d3dx9_36/effect.c
+++ b/dll/directx/wine/d3dx9_36/effect.c
@@ -546,16 +546,21 @@ static void free_sampler(struct d3dx_sampler *sampler)
 
 static void d3dx_pool_release_shared_parameter(struct d3dx_top_level_parameter 
*param);
 
-static void free_parameter_data(struct d3dx_parameter *param, BOOL child)
+static void free_parameter_object_data(struct d3dx_parameter *param, const 
void *data, unsigned int bytes)
 {
-    if (!param->data)
+    unsigned int i, count;
+
+    if (param->class != D3DXPC_OBJECT)
         return;
-    if (param->class == D3DXPC_OBJECT && !param->element_count)
+
+    count = min(param->element_count ? param->element_count : 1, bytes / 
sizeof(void *));
+
+    for (i = 0; i < count; ++i)
     {
         switch (param->type)
         {
             case D3DXPT_STRING:
-                heap_free(*(char **)param->data);
+                heap_free(((char **)data)[i]);
                 break;
 
             case D3DXPT_TEXTURE:
@@ -565,7 +570,8 @@ static void free_parameter_data(struct d3dx_parameter 
*param, BOOL child)
             case D3DXPT_TEXTURECUBE:
             case D3DXPT_PIXELSHADER:
             case D3DXPT_VERTEXSHADER:
-                if (*(IUnknown **)param->data) IUnknown_Release(*(IUnknown 
**)param->data);
+                if (*(IUnknown **)data)
+                    IUnknown_Release(((IUnknown **)data)[i]);
                 break;
 
             case D3DXPT_SAMPLER:
@@ -573,7 +579,8 @@ static void free_parameter_data(struct d3dx_parameter 
*param, BOOL child)
             case D3DXPT_SAMPLER2D:
             case D3DXPT_SAMPLER3D:
             case D3DXPT_SAMPLERCUBE:
-                free_sampler((struct d3dx_sampler *)param->data);
+                assert(count == 1);
+                free_sampler((struct d3dx_sampler *)data);
                 return;
 
             default:
@@ -581,6 +588,16 @@ static void free_parameter_data(struct d3dx_parameter 
*param, BOOL child)
                 break;
         }
     }
+}
+
+static void free_parameter_data(struct d3dx_parameter *param, BOOL child)
+{
+    if (!param->data)
+        return;
+
+    if (!param->element_count)
+        free_parameter_object_data(param, param->data, param->bytes);
+
     if (!child || is_param_type_sampler(param->type))
         heap_free(param->data);
 }
diff --git a/sdk/tools/winesync/d3dx9.cfg b/sdk/tools/winesync/d3dx9.cfg
index 5ef09b584fa..a046e451b04 100644
--- a/sdk/tools/winesync/d3dx9.cfg
+++ b/sdk/tools/winesync/d3dx9.cfg
@@ -15,4 +15,4 @@ files: {include/d3dx9.h: sdk/include/dxsdk/d3dx9.h, 
include/d3dx9anim.h: sdk/inc
   include/d3dx9mesh.h: sdk/include/dxsdk/d3dx9mesh.h, include/d3dx9of.h: 
sdk/include/dxsdk/d3dx9of.h,
   include/d3dx9shader.h: sdk/include/dxsdk/d3dx9shader.h, 
include/d3dx9shape.h: sdk/include/dxsdk/d3dx9shape.h,
   include/d3dx9tex.h: sdk/include/dxsdk/d3dx9tex.h, include/d3dx9xof.h: 
sdk/include/dxsdk/d3dx9xof.h}
-tags: {wine: 4020a38259774c64035e5783d595ff88097cedf8}
+tags: {wine: 07562f1e3927b2aa1521811f0c16a7f05c175cba}

Reply via email to