From: Alex Henrie alexhenrie24@gmail.com
--- dlls/d3dcompiler_43/tests/asm.c | 12 ++++++------ dlls/d3dcompiler_43/tests/hlsl_d3d9.c | 12 ++++-------- 2 files changed, 10 insertions(+), 14 deletions(-)
diff --git a/dlls/d3dcompiler_43/tests/asm.c b/dlls/d3dcompiler_43/tests/asm.c index 6d3e7013017..397454d52ea 100644 --- a/dlls/d3dcompiler_43/tests/asm.c +++ b/dlls/d3dcompiler_43/tests/asm.c @@ -1460,14 +1460,14 @@ static HRESULT WINAPI testD3DInclude_open(ID3DInclude *iface, D3D_INCLUDE_TYPE i
if (!strcmp(filename, "incl.vsh")) { - buffer = HeapAlloc(GetProcessHeap(), 0, sizeof(include)); + buffer = malloc(sizeof(include)); CopyMemory(buffer, include, sizeof(include)); *bytes = sizeof(include); ok(!parent_data, "Wrong parent_data value.\n"); } else if (!strcmp(filename, "incl2.vsh")) { - buffer = HeapAlloc(GetProcessHeap(), 0, sizeof(include2)); + buffer = malloc(sizeof(include2)); CopyMemory(buffer, include2, sizeof(include2)); *bytes = sizeof(include2); ok(!parent_data, "Wrong parent_data value.\n"); @@ -1475,7 +1475,7 @@ static HRESULT WINAPI testD3DInclude_open(ID3DInclude *iface, D3D_INCLUDE_TYPE i } else if (!strcmp(filename, "incl3.vsh")) { - buffer = HeapAlloc(GetProcessHeap(), 0, sizeof(include3)); + buffer = malloc(sizeof(include3)); CopyMemory(buffer, include3, sizeof(include3)); *bytes = sizeof(include3); /* Also check for the correct parent_data content */ @@ -1486,7 +1486,7 @@ static HRESULT WINAPI testD3DInclude_open(ID3DInclude *iface, D3D_INCLUDE_TYPE i } else if (!strcmp(filename, "incl4.vsh")) { - buffer = HeapAlloc(GetProcessHeap(), 0, sizeof(include4)); + buffer = malloc(sizeof(include4)); CopyMemory(buffer, include4, sizeof(include4)); *bytes = sizeof(include4); ok(parent_data == NULL, "Wrong parent_data value.\n"); @@ -1494,7 +1494,7 @@ static HRESULT WINAPI testD3DInclude_open(ID3DInclude *iface, D3D_INCLUDE_TYPE i } else if (!strcmp(filename, "includes/incl.vsh")) { - buffer = HeapAlloc(GetProcessHeap(), 0, sizeof(include)); + buffer = malloc(sizeof(include)); CopyMemory(buffer, include, sizeof(include)); *bytes = sizeof(include); ok(!parent_data, "Wrong parent_data value.\n"); @@ -1512,7 +1512,7 @@ static HRESULT WINAPI testD3DInclude_open(ID3DInclude *iface, D3D_INCLUDE_TYPE i
static HRESULT WINAPI testD3DInclude_close(ID3DInclude *iface, const void *data) { - HeapFree(GetProcessHeap(), 0, (void *)data); + free((void *)data); return S_OK; }
diff --git a/dlls/d3dcompiler_43/tests/hlsl_d3d9.c b/dlls/d3dcompiler_43/tests/hlsl_d3d9.c index c6e7aa367f0..0d016e37956 100644 --- a/dlls/d3dcompiler_43/tests/hlsl_d3d9.c +++ b/dlls/d3dcompiler_43/tests/hlsl_d3d9.c @@ -18,7 +18,6 @@ */ #define COBJMACROS #include "wine/test.h" -#include "wine/heap.h" #include "d3dx9.h" #include "d3dcompiler.h"
@@ -1515,8 +1514,7 @@ static HRESULT WINAPI test_d3dinclude_open(ID3DInclude *iface, D3D_INCLUDE_TYPE
if (!strcmp(filename, "include1.h")) { - buffer = heap_alloc(strlen(include1)); - CopyMemory(buffer, include1, strlen(include1)); + buffer = strdup(include1); *bytes = strlen(include1); ok(include_type == D3D_INCLUDE_LOCAL, "Unexpected include type %d.\n", include_type); ok(!strncmp(include2, parent_data, strlen(include2)) || !strncmp(include3, parent_data, strlen(include3)), @@ -1524,16 +1522,14 @@ static HRESULT WINAPI test_d3dinclude_open(ID3DInclude *iface, D3D_INCLUDE_TYPE } else if (!strcmp(filename, "include\include2.h")) { - buffer = heap_alloc(strlen(include2)); - CopyMemory(buffer, include2, strlen(include2)); + buffer = strdup(include2); *bytes = strlen(include2); ok(!parent_data, "Unexpected parent_data value.\n"); ok(include_type == D3D_INCLUDE_LOCAL, "Unexpected include type %d.\n", include_type); } else if (!strcmp(filename, "include\include3.h")) { - buffer = heap_alloc(strlen(include3)); - CopyMemory(buffer, include3, strlen(include3)); + buffer = strdup(include3); *bytes = strlen(include3); ok(!parent_data, "Unexpected parent_data value.\n"); ok(include_type == D3D_INCLUDE_LOCAL, "Unexpected include type %d.\n", include_type); @@ -1550,7 +1546,7 @@ static HRESULT WINAPI test_d3dinclude_open(ID3DInclude *iface, D3D_INCLUDE_TYPE
static HRESULT WINAPI test_d3dinclude_close(ID3DInclude *iface, const void *data) { - heap_free((void *)data); + free((void *)data); return S_OK; }
Sorry, I missed this MR somehow.
It seems to me that this patch does it backwards, in a way. Specifically, the HeapAlloc(sizeof(string)) are replaced with malloc(), while the heap_alloc(strlen(string)) + CopyMemory() become strdup(). The former is okay, although we could replace the whole memory allocation + string copy with strdup() just fine. The latter changes behavior slightly, in that it was previously copying the string without the string terminator while now it allocates and copies that extra byte. Now, to be fair, this effectively "depended" on the arbitrary value that happens to be on that (last + 1) byte, but then again it should probably be improved anyway to allocate the extra byte and explicitly set it to some value != 0.