mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-14 19:27:17 +00:00
d3d8/tests: Use CRT allocation functions.
This commit is contained in:
parent
a70e3059c6
commit
6db89702a3
|
@ -26,7 +26,6 @@
|
|||
#include <initguid.h>
|
||||
#include <d3d8.h>
|
||||
#include "wine/test.h"
|
||||
#include "wine/heap.h"
|
||||
|
||||
struct vec3
|
||||
{
|
||||
|
@ -129,7 +128,7 @@ static BOOL save_display_modes(DEVMODEW **original_modes, unsigned int *display_
|
|||
DISPLAY_DEVICEW display_device;
|
||||
DEVMODEW *modes, *tmp;
|
||||
|
||||
if (!(modes = heap_alloc(size * sizeof(*modes))))
|
||||
if (!(modes = malloc(size * sizeof(*modes))))
|
||||
return FALSE;
|
||||
|
||||
display_device.cb = sizeof(display_device);
|
||||
|
@ -145,9 +144,9 @@ static BOOL save_display_modes(DEVMODEW **original_modes, unsigned int *display_
|
|||
if (count >= size)
|
||||
{
|
||||
size *= 2;
|
||||
if (!(tmp = heap_realloc(modes, size * sizeof(*modes))))
|
||||
if (!(tmp = realloc(modes, size * sizeof(*modes))))
|
||||
{
|
||||
heap_free(modes);
|
||||
free(modes);
|
||||
return FALSE;
|
||||
}
|
||||
modes = tmp;
|
||||
|
@ -157,7 +156,7 @@ static BOOL save_display_modes(DEVMODEW **original_modes, unsigned int *display_
|
|||
modes[count].dmSize = sizeof(modes[count]);
|
||||
if (!EnumDisplaySettingsW(display_device.DeviceName, ENUM_CURRENT_SETTINGS, &modes[count]))
|
||||
{
|
||||
heap_free(modes);
|
||||
free(modes);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -1554,7 +1553,7 @@ static void test_reset(void)
|
|||
hr = IDirect3D8_GetAdapterDisplayMode(d3d8, D3DADAPTER_DEFAULT, &d3ddm);
|
||||
ok(SUCCEEDED(hr), "GetAdapterDisplayMode failed, hr %#lx.\n", hr);
|
||||
adapter_mode_count = IDirect3D8_GetAdapterModeCount(d3d8, D3DADAPTER_DEFAULT);
|
||||
modes = HeapAlloc(GetProcessHeap(), 0, sizeof(*modes) * adapter_mode_count);
|
||||
modes = malloc(sizeof(*modes) * adapter_mode_count);
|
||||
for (i = 0; i < adapter_mode_count; ++i)
|
||||
{
|
||||
UINT j;
|
||||
|
@ -2120,7 +2119,7 @@ static void test_reset(void)
|
|||
IDirect3DSurface8_Release(surface);
|
||||
|
||||
cleanup:
|
||||
HeapFree(GetProcessHeap(), 0, modes);
|
||||
free(modes);
|
||||
if (device2)
|
||||
IDirect3DDevice8_Release(device2);
|
||||
if (device1)
|
||||
|
@ -2264,7 +2263,7 @@ static void test_shader(void)
|
|||
hr = IDirect3DDevice8_GetVertexShaderDeclaration(device, hVertexShader, NULL, &data_size);
|
||||
ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
|
||||
ok(data_size == vertex_decl_size, "Got data_size %lu, expected %lu.\n", data_size, vertex_decl_size);
|
||||
data = HeapAlloc(GetProcessHeap(), 0, vertex_decl_size);
|
||||
data = malloc(vertex_decl_size);
|
||||
data_size = 1;
|
||||
hr = IDirect3DDevice8_GetVertexShaderDeclaration(device, hVertexShader, data, &data_size);
|
||||
ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
|
||||
|
@ -2274,12 +2273,12 @@ static void test_shader(void)
|
|||
ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
|
||||
ok(data_size == vertex_decl_size, "Got data_size %lu, expected %lu.\n", data_size, vertex_decl_size);
|
||||
ok(!memcmp(data, dwVertexDecl, vertex_decl_size), "data not equal to shader declaration\n");
|
||||
HeapFree(GetProcessHeap(), 0, data);
|
||||
free(data);
|
||||
/* Verify that we can retrieve the shader function */
|
||||
hr = IDirect3DDevice8_GetVertexShaderFunction(device, hVertexShader, NULL, &data_size);
|
||||
ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
|
||||
ok(data_size == simple_vs_size, "Got data_size %lu, expected %lu.\n", data_size, simple_vs_size);
|
||||
data = HeapAlloc(GetProcessHeap(), 0, simple_vs_size);
|
||||
data = malloc(simple_vs_size);
|
||||
data_size = 1;
|
||||
hr = IDirect3DDevice8_GetVertexShaderFunction(device, hVertexShader, data, &data_size);
|
||||
ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
|
||||
|
@ -2289,7 +2288,7 @@ static void test_shader(void)
|
|||
ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
|
||||
ok(data_size == simple_vs_size, "Got data_size %lu, expected %lu.\n", data_size, simple_vs_size);
|
||||
ok(!memcmp(data, simple_vs, simple_vs_size), "data not equal to shader function\n");
|
||||
HeapFree(GetProcessHeap(), 0, data);
|
||||
free(data);
|
||||
/* Delete the assigned shader. This is supposed to work */
|
||||
hr = IDirect3DDevice8_DeleteVertexShader(device, hVertexShader);
|
||||
ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
|
||||
|
@ -2331,7 +2330,7 @@ static void test_shader(void)
|
|||
hr = IDirect3DDevice8_GetPixelShaderFunction(device, hPixelShader, NULL, &data_size);
|
||||
ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
|
||||
ok(data_size == simple_ps_size, "Got data_size %lu, expected %lu.\n", data_size, simple_ps_size);
|
||||
data = HeapAlloc(GetProcessHeap(), 0, simple_ps_size);
|
||||
data = malloc(simple_ps_size);
|
||||
data_size = 1;
|
||||
hr = IDirect3DDevice8_GetPixelShaderFunction(device, hPixelShader, data, &data_size);
|
||||
ok(hr == D3DERR_INVALIDCALL, "Got hr %#lx.\n", hr);
|
||||
|
@ -2341,7 +2340,7 @@ static void test_shader(void)
|
|||
ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
|
||||
ok(data_size == simple_ps_size, "Got data_size %lu, expected %lu.\n", data_size, simple_ps_size);
|
||||
ok(!memcmp(data, simple_ps, simple_ps_size), "data not equal to shader function\n");
|
||||
HeapFree(GetProcessHeap(), 0, data);
|
||||
free(data);
|
||||
/* Delete the assigned shader. This is supposed to work */
|
||||
hr = IDirect3DDevice8_DeletePixelShader(device, hPixelShader);
|
||||
ok(hr == D3D_OK, "Got hr %#lx.\n", hr);
|
||||
|
@ -4711,7 +4710,7 @@ done:
|
|||
IDirect3D8_Release(d3d8);
|
||||
ret = restore_display_modes(original_modes, display_count);
|
||||
ok(ret, "Failed to restore display modes.\n");
|
||||
heap_free(original_modes);
|
||||
free(original_modes);
|
||||
}
|
||||
|
||||
static void test_device_window_reset(void)
|
||||
|
@ -5052,11 +5051,11 @@ static void test_validate_vs(void)
|
|||
hr = ValidateVertexShader(NULL, NULL, NULL, FALSE, &errors);
|
||||
ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
|
||||
ok(!*errors, "Got unexpected string \"%s\".\n", errors);
|
||||
heap_free(errors);
|
||||
free(errors);
|
||||
hr = ValidateVertexShader(NULL, NULL, NULL, TRUE, &errors);
|
||||
ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
|
||||
ok(!!*errors, "Got unexpected empty string.\n");
|
||||
heap_free(errors);
|
||||
free(errors);
|
||||
|
||||
hr = ValidateVertexShader(vs_code, NULL, NULL, FALSE, NULL);
|
||||
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
|
||||
|
@ -5065,7 +5064,7 @@ static void test_validate_vs(void)
|
|||
hr = ValidateVertexShader(vs_code, NULL, NULL, TRUE, &errors);
|
||||
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
|
||||
ok(!*errors, "Got unexpected string \"%s\".\n", errors);
|
||||
heap_free(errors);
|
||||
free(errors);
|
||||
|
||||
hr = ValidateVertexShader(vs_code, declaration_valid1, NULL, FALSE, NULL);
|
||||
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
|
||||
|
@ -5102,11 +5101,11 @@ static void test_validate_vs(void)
|
|||
hr = ValidateVertexShader(vs_code, NULL, NULL, FALSE, &errors);
|
||||
ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
|
||||
ok(!*errors, "Got unexpected string \"%s\".\n", errors);
|
||||
heap_free(errors);
|
||||
free(errors);
|
||||
hr = ValidateVertexShader(vs_code, NULL, NULL, TRUE, &errors);
|
||||
ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
|
||||
ok(!!*errors, "Got unexpected empty string.\n");
|
||||
heap_free(errors);
|
||||
free(errors);
|
||||
}
|
||||
|
||||
static void test_validate_ps(void)
|
||||
|
@ -5150,7 +5149,7 @@ static void test_validate_ps(void)
|
|||
hr = ValidatePixelShader(ps_1_1_code, NULL, TRUE, &errors);
|
||||
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
|
||||
ok(!*errors, "Got unexpected string \"%s\".\n", errors);
|
||||
heap_free(errors);
|
||||
free(errors);
|
||||
|
||||
memset(&caps, 0, sizeof(caps));
|
||||
caps.PixelShaderVersion = D3DPS_VERSION(1, 1);
|
||||
|
@ -5180,11 +5179,11 @@ static void test_validate_ps(void)
|
|||
hr = ValidatePixelShader(ps_1_1_code, NULL, FALSE, &errors);
|
||||
ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
|
||||
ok(!*errors, "Got unexpected string \"%s\".\n", errors);
|
||||
heap_free(errors);
|
||||
free(errors);
|
||||
hr = ValidatePixelShader(ps_1_1_code, NULL, TRUE, &errors);
|
||||
ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
|
||||
ok(!!*errors, "Got unexpected empty string.\n");
|
||||
heap_free(errors);
|
||||
free(errors);
|
||||
}
|
||||
|
||||
static void test_volume_get_container(void)
|
||||
|
|
|
@ -1408,7 +1408,7 @@ static HRESULT render_state_test_init(IDirect3DDevice8 *device, struct state_tes
|
|||
const struct render_state_arg *rsarg = test->test_arg;
|
||||
unsigned int i, j;
|
||||
|
||||
struct render_state_context *ctx = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ctx));
|
||||
struct render_state_context *ctx = calloc(1, sizeof(*ctx));
|
||||
if (!ctx) return E_FAIL;
|
||||
test->test_context = ctx;
|
||||
|
||||
|
@ -1451,7 +1451,7 @@ static HRESULT render_state_test_init(IDirect3DDevice8 *device, struct state_tes
|
|||
|
||||
static void render_state_test_cleanup(IDirect3DDevice8 *device, struct state_test *test)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, test->test_context);
|
||||
free(test->test_context);
|
||||
}
|
||||
|
||||
static void render_states_queue_test(struct state_test *test, const struct render_state_arg *test_arg)
|
||||
|
@ -1590,12 +1590,12 @@ static void resource_default_data_init(struct resource_test_data *data, const st
|
|||
data->vs = 0;
|
||||
data->ps = 0;
|
||||
data->ib = NULL;
|
||||
data->vb = HeapAlloc(GetProcessHeap(), 0, arg->stream_count * sizeof(*data->vb));
|
||||
data->vb = malloc(arg->stream_count * sizeof(*data->vb));
|
||||
for (i = 0; i < arg->stream_count; ++i)
|
||||
{
|
||||
data->vb[i] = NULL;
|
||||
}
|
||||
data->tex = HeapAlloc(GetProcessHeap(), 0, arg->tex_count * sizeof(*data->tex));
|
||||
data->tex = malloc(arg->tex_count * sizeof(*data->tex));
|
||||
for (i = 0; i < arg->tex_count; ++i)
|
||||
{
|
||||
data->tex[i] = NULL;
|
||||
|
@ -1650,7 +1650,7 @@ static void resource_test_data_init(IDirect3DDevice8 *device,
|
|||
hr = IDirect3DDevice8_CreateIndexBuffer(device, 64, D3DUSAGE_DYNAMIC, D3DFMT_INDEX32, D3DPOOL_DEFAULT, &data->ib);
|
||||
ok(SUCCEEDED(hr), "CreateIndexBuffer returned hr %#lx.\n", hr);
|
||||
|
||||
data->vb = HeapAlloc(GetProcessHeap(), 0, arg->stream_count * sizeof(*data->vb));
|
||||
data->vb = malloc(arg->stream_count * sizeof(*data->vb));
|
||||
for (i = 0; i < arg->stream_count; ++i)
|
||||
{
|
||||
hr = IDirect3DDevice8_CreateVertexBuffer(device, 64, D3DUSAGE_DYNAMIC,
|
||||
|
@ -1658,7 +1658,7 @@ static void resource_test_data_init(IDirect3DDevice8 *device,
|
|||
ok(SUCCEEDED(hr), "CreateVertexBuffer (%u) returned hr %#lx.\n", i, hr);
|
||||
}
|
||||
|
||||
data->tex = HeapAlloc(GetProcessHeap(), 0, arg->tex_count * sizeof(*data->tex));
|
||||
data->tex = malloc(arg->tex_count * sizeof(*data->tex));
|
||||
for (i = 0; i < arg->tex_count; ++i)
|
||||
{
|
||||
hr = IDirect3DDevice8_CreateTexture(device, 64, 64, 0, 0,
|
||||
|
@ -1675,12 +1675,12 @@ static void resource_poison_data_init(struct resource_test_data *data, const str
|
|||
data->vs = poison++;
|
||||
data->ps = poison++;
|
||||
data->ib = (IDirect3DIndexBuffer8 *)poison++;
|
||||
data->vb = HeapAlloc(GetProcessHeap(), 0, arg->stream_count * sizeof(*data->vb));
|
||||
data->vb = malloc(arg->stream_count * sizeof(*data->vb));
|
||||
for (i = 0; i < arg->stream_count; ++i)
|
||||
{
|
||||
data->vb[i] = (IDirect3DVertexBuffer8 *)poison++;
|
||||
}
|
||||
data->tex = HeapAlloc(GetProcessHeap(), 0, arg->tex_count * sizeof(*data->tex));
|
||||
data->tex = malloc(arg->tex_count * sizeof(*data->tex));
|
||||
for (i = 0; i < arg->tex_count; ++i)
|
||||
{
|
||||
data->tex[i] = (IDirect3DTexture8 *)poison++;
|
||||
|
@ -1692,7 +1692,7 @@ static HRESULT resource_test_init(IDirect3DDevice8 *device, struct state_test *t
|
|||
const struct resource_test_arg *arg = test->test_arg;
|
||||
struct resource_test_context *ctx;
|
||||
|
||||
ctx = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ctx));
|
||||
ctx = calloc(1, sizeof(*ctx));
|
||||
if (!ctx) return E_OUTOFMEMORY;
|
||||
|
||||
test->test_context = ctx;
|
||||
|
@ -1747,17 +1747,17 @@ static void resource_test_cleanup(IDirect3DDevice8 *device, struct state_test *t
|
|||
IDirect3DBaseTexture8_Release(ctx->test_data_all.tex[i]);
|
||||
}
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, ctx->default_data.vb);
|
||||
HeapFree(GetProcessHeap(), 0, ctx->default_data.tex);
|
||||
HeapFree(GetProcessHeap(), 0, ctx->test_data_all.vb);
|
||||
HeapFree(GetProcessHeap(), 0, ctx->test_data_all.tex);
|
||||
HeapFree(GetProcessHeap(), 0, ctx->test_data_vertex.vb);
|
||||
HeapFree(GetProcessHeap(), 0, ctx->test_data_vertex.tex);
|
||||
HeapFree(GetProcessHeap(), 0, ctx->test_data_pixel.vb);
|
||||
HeapFree(GetProcessHeap(), 0, ctx->test_data_pixel.tex);
|
||||
HeapFree(GetProcessHeap(), 0, ctx->poison_data.vb);
|
||||
HeapFree(GetProcessHeap(), 0, ctx->poison_data.tex);
|
||||
HeapFree(GetProcessHeap(), 0, ctx);
|
||||
free(ctx->default_data.vb);
|
||||
free(ctx->default_data.tex);
|
||||
free(ctx->test_data_all.vb);
|
||||
free(ctx->test_data_all.tex);
|
||||
free(ctx->test_data_vertex.vb);
|
||||
free(ctx->test_data_vertex.tex);
|
||||
free(ctx->test_data_pixel.vb);
|
||||
free(ctx->test_data_pixel.tex);
|
||||
free(ctx->poison_data.vb);
|
||||
free(ctx->poison_data.tex);
|
||||
free(ctx);
|
||||
}
|
||||
|
||||
static void resource_test_queue(struct state_test *test, const struct resource_test_arg *test_arg)
|
||||
|
|
|
@ -941,8 +941,8 @@ static void test_specular_lighting(void)
|
|||
} *quad;
|
||||
WORD *indices;
|
||||
|
||||
quad = HeapAlloc(GetProcessHeap(), 0, vertices_side * vertices_side * sizeof(*quad));
|
||||
indices = HeapAlloc(GetProcessHeap(), 0, indices_count * sizeof(*indices));
|
||||
quad = malloc(vertices_side * vertices_side * sizeof(*quad));
|
||||
indices = malloc(indices_count * sizeof(*indices));
|
||||
for (i = 0, y = 0; y < vertices_side; ++y)
|
||||
{
|
||||
for (x = 0; x < vertices_side; ++x)
|
||||
|
@ -1044,8 +1044,8 @@ static void test_specular_lighting(void)
|
|||
done:
|
||||
IDirect3D8_Release(d3d);
|
||||
DestroyWindow(window);
|
||||
HeapFree(GetProcessHeap(), 0, indices);
|
||||
HeapFree(GetProcessHeap(), 0, quad);
|
||||
free(indices);
|
||||
free(quad);
|
||||
}
|
||||
|
||||
static void clear_test(void)
|
||||
|
|
Loading…
Reference in a new issue