Commit bc13bda5 authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

d3dx9_36/tests: Use CRT allocation functions.

parent 14158bb5
...@@ -111,14 +111,14 @@ static HRESULT WINAPI testD3DXInclude_open(ID3DXInclude *iface, D3DXINCLUDE_TYPE ...@@ -111,14 +111,14 @@ static HRESULT WINAPI testD3DXInclude_open(ID3DXInclude *iface, D3DXINCLUDE_TYPE
if (!strcmp(filename, "shader.vsh")) if (!strcmp(filename, "shader.vsh"))
{ {
size = test_include->terminated_data ? sizeof(shader) : sizeof(shader) - 1; size = test_include->terminated_data ? sizeof(shader) : sizeof(shader) - 1;
buffer = HeapAlloc(GetProcessHeap(), 0, size); buffer = malloc(size);
memcpy(buffer, shader, size); memcpy(buffer, shader, size);
*bytes = size; *bytes = size;
} }
else if (!strcmp(filename, "incl.vsh")) else if (!strcmp(filename, "incl.vsh"))
{ {
size = test_include->terminated_data ? sizeof(include) : sizeof(include) - 1; size = test_include->terminated_data ? sizeof(include) : sizeof(include) - 1;
buffer = HeapAlloc(GetProcessHeap(), 0, size); buffer = malloc(size);
memcpy(buffer, include, size); memcpy(buffer, include, size);
*bytes = size; *bytes = size;
/* This is included from the first D3DXAssembleShader with non-null ID3DXInclude test /* This is included from the first D3DXAssembleShader with non-null ID3DXInclude test
...@@ -129,14 +129,14 @@ static HRESULT WINAPI testD3DXInclude_open(ID3DXInclude *iface, D3DXINCLUDE_TYPE ...@@ -129,14 +129,14 @@ static HRESULT WINAPI testD3DXInclude_open(ID3DXInclude *iface, D3DXINCLUDE_TYPE
else if (!strcmp(filename, "incl2.vsh")) else if (!strcmp(filename, "incl2.vsh"))
{ {
size = test_include->terminated_data ? sizeof(include2) : sizeof(include2) - 1; size = test_include->terminated_data ? sizeof(include2) : sizeof(include2) - 1;
buffer = HeapAlloc(GetProcessHeap(), 0, size); buffer = malloc(size);
memcpy(buffer, include2, size); memcpy(buffer, include2, size);
*bytes = size; *bytes = size;
} }
else if (!strcmp(filename, "incl3.vsh")) else if (!strcmp(filename, "incl3.vsh"))
{ {
size = test_include->terminated_data ? sizeof(include3) : sizeof(include3) - 1; size = test_include->terminated_data ? sizeof(include3) : sizeof(include3) - 1;
buffer = HeapAlloc(GetProcessHeap(), 0, size); buffer = malloc(size);
memcpy(buffer, include3, size); memcpy(buffer, include3, size);
*bytes = size; *bytes = size;
ok(parent_data != NULL && !strncmp(include2, parent_data, strlen(include2)), "wrong parent_data value.\n"); ok(parent_data != NULL && !strncmp(include2, parent_data, strlen(include2)), "wrong parent_data value.\n");
...@@ -144,7 +144,7 @@ static HRESULT WINAPI testD3DXInclude_open(ID3DXInclude *iface, D3DXINCLUDE_TYPE ...@@ -144,7 +144,7 @@ static HRESULT WINAPI testD3DXInclude_open(ID3DXInclude *iface, D3DXINCLUDE_TYPE
else if (!strcmp(filename, "include/incl3.vsh")) else if (!strcmp(filename, "include/incl3.vsh"))
{ {
size = test_include->terminated_data ? sizeof(include) : sizeof(include) - 1; size = test_include->terminated_data ? sizeof(include) : sizeof(include) - 1;
buffer = HeapAlloc(GetProcessHeap(), 0, size); buffer = malloc(size);
memcpy(buffer, include, size); memcpy(buffer, include, size);
*bytes = size; *bytes = size;
ok(!parent_data, "wrong parent_data value.\n"); ok(!parent_data, "wrong parent_data value.\n");
...@@ -160,7 +160,7 @@ static HRESULT WINAPI testD3DXInclude_open(ID3DXInclude *iface, D3DXINCLUDE_TYPE ...@@ -160,7 +160,7 @@ static HRESULT WINAPI testD3DXInclude_open(ID3DXInclude *iface, D3DXINCLUDE_TYPE
static HRESULT WINAPI testD3DXInclude_close(ID3DXInclude *iface, const void *data) static HRESULT WINAPI testD3DXInclude_close(ID3DXInclude *iface, const void *data)
{ {
HeapFree(GetProcessHeap(), 0, (void *)data); free((void *)data);
return S_OK; return S_OK;
} }
......
...@@ -3087,13 +3087,13 @@ static void test_effect_states(IDirect3DDevice9 *device) ...@@ -3087,13 +3087,13 @@ static void test_effect_states(IDirect3DDevice9 *device)
ok(vshader != NULL, "Unexpected vshader %p.\n", vshader); ok(vshader != NULL, "Unexpected vshader %p.\n", vshader);
hr = IDirect3DVertexShader9_GetFunction(vshader, NULL, &byte_code_size); hr = IDirect3DVertexShader9_GetFunction(vshader, NULL, &byte_code_size);
ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr); ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
byte_code = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, byte_code_size); byte_code = calloc(1, byte_code_size);
hr = IDirect3DVertexShader9_GetFunction(vshader, byte_code, &byte_code_size); hr = IDirect3DVertexShader9_GetFunction(vshader, byte_code, &byte_code_size);
ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr); ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
ok(byte_code_size > 1, "Got unexpected byte code size %u.\n", byte_code_size); ok(byte_code_size > 1, "Got unexpected byte code size %u.\n", byte_code_size);
ok(!memcmp(byte_code, &test_effect_states_effect_blob[TEST_EFFECT_STATES_VSHADER_POS], byte_code_size), ok(!memcmp(byte_code, &test_effect_states_effect_blob[TEST_EFFECT_STATES_VSHADER_POS], byte_code_size),
"Incorrect shader selected.\n"); "Incorrect shader selected.\n");
HeapFree(GetProcessHeap(), 0, byte_code); free(byte_code);
IDirect3DVertexShader9_Release(vshader); IDirect3DVertexShader9_Release(vshader);
hr = IDirect3DDevice9_GetLightEnable(device, 2, &bval); hr = IDirect3DDevice9_GetLightEnable(device, 2, &bval);
...@@ -4281,14 +4281,14 @@ static void test_effect_preshader_compare_shader_(unsigned int line, IDirect3DDe ...@@ -4281,14 +4281,14 @@ static void test_effect_preshader_compare_shader_(unsigned int line, IDirect3DDe
ok_(__FILE__, line)(hr == D3D_OK, "IDirect3DVertexShader9_GetFunction %#lx.\n", hr); ok_(__FILE__, line)(hr == D3D_OK, "IDirect3DVertexShader9_GetFunction %#lx.\n", hr);
ok_(__FILE__, line)(byte_code_size > 1, "Got unexpected byte code size %u.\n", byte_code_size); ok_(__FILE__, line)(byte_code_size > 1, "Got unexpected byte code size %u.\n", byte_code_size);
byte_code = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, byte_code_size); byte_code = calloc(1, byte_code_size);
hr = IDirect3DVertexShader9_GetFunction(vshader, byte_code, &byte_code_size); hr = IDirect3DVertexShader9_GetFunction(vshader, byte_code, &byte_code_size);
ok_(__FILE__, line)(hr == D3D_OK, "Got result %#lx.\n", hr); ok_(__FILE__, line)(hr == D3D_OK, "Got result %#lx.\n", hr);
test_effect_preshader_compare_shader_bytecode_(line, byte_code, test_effect_preshader_compare_shader_bytecode_(line, byte_code,
byte_code_size, expected_shader_index, todo); byte_code_size, expected_shader_index, todo);
HeapFree(GetProcessHeap(), 0, byte_code); free(byte_code);
IDirect3DVertexShader9_Release(vshader); IDirect3DVertexShader9_Release(vshader);
} }
...@@ -6048,7 +6048,7 @@ static struct test_manager *impl_from_ID3DXEffectStateManager(ID3DXEffectStateMa ...@@ -6048,7 +6048,7 @@ static struct test_manager *impl_from_ID3DXEffectStateManager(ID3DXEffectStateMa
static void free_test_effect_state_manager(struct test_manager *state_manager) static void free_test_effect_state_manager(struct test_manager *state_manager)
{ {
HeapFree(GetProcessHeap(), 0, state_manager->update_record); free(state_manager->update_record);
state_manager->update_record = NULL; state_manager->update_record = NULL;
IDirect3DDevice9_Release(state_manager->device); IDirect3DDevice9_Release(state_manager->device);
...@@ -6069,7 +6069,7 @@ static ULONG WINAPI test_manager_Release(ID3DXEffectStateManager *iface) ...@@ -6069,7 +6069,7 @@ static ULONG WINAPI test_manager_Release(ID3DXEffectStateManager *iface)
if (!ref) if (!ref)
{ {
free_test_effect_state_manager(state_manager); free_test_effect_state_manager(state_manager);
HeapFree(GetProcessHeap(), 0, state_manager); free(state_manager);
} }
return ref; return ref;
} }
...@@ -6082,17 +6082,11 @@ static HRESULT test_process_set_state(ID3DXEffectStateManager *iface, ...@@ -6082,17 +6082,11 @@ static HRESULT test_process_set_state(ID3DXEffectStateManager *iface,
if (state_manager->update_record_count == state_manager->update_record_size) if (state_manager->update_record_count == state_manager->update_record_size)
{ {
if (!state_manager->update_record_size) if (!state_manager->update_record_size)
{
state_manager->update_record_size = INITIAL_UPDATE_RECORD_SIZE; state_manager->update_record_size = INITIAL_UPDATE_RECORD_SIZE;
state_manager->update_record = HeapAlloc(GetProcessHeap(), 0,
sizeof(*state_manager->update_record) * state_manager->update_record_size);
}
else else
{
state_manager->update_record_size *= 2; state_manager->update_record_size *= 2;
state_manager->update_record = HeapReAlloc(GetProcessHeap(), 0, state_manager->update_record, state_manager->update_record = realloc(state_manager->update_record,
sizeof(*state_manager->update_record) * state_manager->update_record_size); sizeof(*state_manager->update_record) * state_manager->update_record_size);
}
} }
state_manager->update_record[state_manager->update_record_count].state_op = state_op; state_manager->update_record[state_manager->update_record_count].state_op = state_op;
state_manager->update_record[state_manager->update_record_count].param1 = param1; state_manager->update_record[state_manager->update_record_count].param1 = param1;
...@@ -6338,7 +6332,7 @@ static void test_effect_state_manager(IDirect3DDevice9 *device) ...@@ -6338,7 +6332,7 @@ static void test_effect_state_manager(IDirect3DDevice9 *device)
ULONG refcount; ULONG refcount;
HRESULT hr; HRESULT hr;
state_manager = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*state_manager)); state_manager = calloc(1, sizeof(*state_manager));
test_effect_state_manager_init(state_manager, device); test_effect_state_manager_init(state_manager, device);
for (i = 0; i < 8; ++i) for (i = 0; i < 8; ++i)
...@@ -7229,7 +7223,7 @@ static void test_effect_unsupported_shader(void) ...@@ -7229,7 +7223,7 @@ static void test_effect_unsupported_shader(void)
ok(!!vshader, "Got NULL vshader.\n"); ok(!!vshader, "Got NULL vshader.\n");
hr = IDirect3DVertexShader9_GetFunction(vshader, NULL, &byte_code_size); hr = IDirect3DVertexShader9_GetFunction(vshader, NULL, &byte_code_size);
ok(hr == D3D_OK, "Got result %lx.\n", hr); ok(hr == D3D_OK, "Got result %lx.\n", hr);
byte_code = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, byte_code_size); byte_code = calloc(1, byte_code_size);
hr = IDirect3DVertexShader9_GetFunction(vshader, byte_code, &byte_code_size); hr = IDirect3DVertexShader9_GetFunction(vshader, byte_code, &byte_code_size);
ok(hr == D3D_OK, "Got result %lx.\n", hr); ok(hr == D3D_OK, "Got result %lx.\n", hr);
ok(byte_code_size == TEST_EFFECT_UNSUPPORTED_SHADER_BYTECODE_VS_3_0_LEN * sizeof(DWORD), ok(byte_code_size == TEST_EFFECT_UNSUPPORTED_SHADER_BYTECODE_VS_3_0_LEN * sizeof(DWORD),
...@@ -7237,7 +7231,7 @@ static void test_effect_unsupported_shader(void) ...@@ -7237,7 +7231,7 @@ static void test_effect_unsupported_shader(void)
ok(!memcmp(byte_code, ok(!memcmp(byte_code,
&test_effect_unsupported_shader_blob[TEST_EFFECT_UNSUPPORTED_SHADER_BYTECODE_VS_3_0_POS], &test_effect_unsupported_shader_blob[TEST_EFFECT_UNSUPPORTED_SHADER_BYTECODE_VS_3_0_POS],
byte_code_size), "Incorrect shader selected.\n"); byte_code_size), "Incorrect shader selected.\n");
HeapFree(GetProcessHeap(), 0, byte_code); free(byte_code);
IDirect3DVertexShader9_Release(vshader); IDirect3DVertexShader9_Release(vshader);
hr = effect->lpVtbl->SetInt(effect, "i", 1); hr = effect->lpVtbl->SetInt(effect, "i", 1);
...@@ -7439,7 +7433,7 @@ static void test_effect_clone(void) ...@@ -7439,7 +7433,7 @@ static void test_effect_clone(void)
if (!(device = create_device(&window))) if (!(device = create_device(&window)))
return; return;
state_manager = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*state_manager)); state_manager = calloc(1, sizeof(*state_manager));
test_effect_state_manager_init(state_manager, device); test_effect_state_manager_init(state_manager, device);
hr = IDirect3DDevice9_CreateTexture(device, 16, 16, 1, 0, D3DFMT_X8R8G8B8, hr = IDirect3DDevice9_CreateTexture(device, 16, 16, 1, 0, D3DFMT_X8R8G8B8,
...@@ -7846,21 +7840,21 @@ static HRESULT WINAPI d3dxinclude_open(ID3DXInclude *iface, D3DXINCLUDE_TYPE inc ...@@ -7846,21 +7840,21 @@ static HRESULT WINAPI d3dxinclude_open(ID3DXInclude *iface, D3DXINCLUDE_TYPE inc
if (!strcmp(filename, "effect2.fx")) if (!strcmp(filename, "effect2.fx"))
{ {
buffer = HeapAlloc(GetProcessHeap(), 0, sizeof(effect2)); buffer = malloc(sizeof(effect2));
memcpy(buffer, effect2, sizeof(effect2)); memcpy(buffer, effect2, sizeof(effect2));
*bytes = sizeof(effect2); *bytes = sizeof(effect2);
ok(!parent_data, "Unexpected parent_data value.\n"); ok(!parent_data, "Unexpected parent_data value.\n");
} }
else if (!strcmp(filename, "include1.h")) else if (!strcmp(filename, "include1.h"))
{ {
buffer = HeapAlloc(GetProcessHeap(), 0, sizeof(include1)); buffer = malloc(sizeof(include1));
memcpy(buffer, include1, sizeof(include1)); memcpy(buffer, include1, sizeof(include1));
*bytes = sizeof(include1); *bytes = sizeof(include1);
ok(!strncmp(parent_data, include2, strlen(include2)), "Unexpected parent_data value.\n"); ok(!strncmp(parent_data, include2, strlen(include2)), "Unexpected parent_data value.\n");
} }
else if (!strcmp(filename, "include\\include2.h")) else if (!strcmp(filename, "include\\include2.h"))
{ {
buffer = HeapAlloc(GetProcessHeap(), 0, sizeof(include2)); buffer = malloc(sizeof(include2));
memcpy(buffer, include2, sizeof(include2)); memcpy(buffer, include2, sizeof(include2));
*bytes = sizeof(include2); *bytes = sizeof(include2);
todo_wine ok(parent_data && !strncmp(parent_data, effect2, strlen(effect2)), todo_wine ok(parent_data && !strncmp(parent_data, effect2, strlen(effect2)),
...@@ -7877,7 +7871,7 @@ static HRESULT WINAPI d3dxinclude_open(ID3DXInclude *iface, D3DXINCLUDE_TYPE inc ...@@ -7877,7 +7871,7 @@ static HRESULT WINAPI d3dxinclude_open(ID3DXInclude *iface, D3DXINCLUDE_TYPE inc
static HRESULT WINAPI d3dxinclude_close(ID3DXInclude *iface, const void *data) static HRESULT WINAPI d3dxinclude_close(ID3DXInclude *iface, const void *data)
{ {
HeapFree(GetProcessHeap(), 0, (void *)data); free((void *)data);
return S_OK; return S_OK;
} }
......
...@@ -524,7 +524,7 @@ static void test_dds_header_handling(void) ...@@ -524,7 +524,7 @@ static void test_dds_header_handling(void)
{ { 32, DDS_PF_RGB, 0, 24, 0xff0000, 0x00ff00, 0x0000ff, 0x000000 }, 0, 256, 256, 0, 10, 262146, { D3D_OK, 10 } }, { { 32, DDS_PF_RGB, 0, 24, 0xff0000, 0x00ff00, 0x0000ff, 0x000000 }, 0, 256, 256, 0, 10, 262146, { D3D_OK, 10 } },
}; };
dds = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*dds)); dds = calloc(1, sizeof(*dds));
if (!dds) if (!dds)
{ {
skip("Failed to allocate memory.\n"); skip("Failed to allocate memory.\n");
...@@ -555,7 +555,7 @@ static void test_dds_header_handling(void) ...@@ -555,7 +555,7 @@ static void test_dds_header_handling(void)
} }
} }
HeapFree(GetProcessHeap(), 0, dds); free(dds);
} }
static void test_D3DXGetImageInfo(void) static void test_D3DXGetImageInfo(void)
......
...@@ -335,7 +335,7 @@ static void test_dump(void) ...@@ -335,7 +335,7 @@ static void test_dump(void)
if (file == INVALID_HANDLE_VALUE) if (file == INVALID_HANDLE_VALUE)
return; return;
data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 10000); data = calloc(1, 10000);
if (!ReadFile(file, data, 10000, &size, NULL)) if (!ReadFile(file, data, 10000, &size, NULL))
{ {
...@@ -376,7 +376,7 @@ static void test_dump(void) ...@@ -376,7 +376,7 @@ static void test_dump(void)
exit: exit:
CloseHandle(file); CloseHandle(file);
HeapFree(GetProcessHeap(), 0, data); free(data);
} }
START_TEST(xfile) START_TEST(xfile)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment