d3d9/tests: Use CRT allocation functions.

This commit is contained in:
Alex Henrie 2023-10-29 10:46:07 -06:00 committed by Alexandre Julliard
parent 9a5b854e2b
commit 042f9304cc
4 changed files with 49 additions and 51 deletions

View file

@ -752,7 +752,7 @@ static void test_user_memory(void)
hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
ok(SUCCEEDED(hr), "Failed to get caps, hr %#lx.\n", hr);
mem = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 128 * 128 * 4);
mem = calloc(128 * 128, 4);
hr = IDirect3DDevice9Ex_CreateTexture(device, 128, 128, 0, 0, D3DFMT_A8R8G8B8,
D3DPOOL_SYSTEMMEM, &texture, &mem);
ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
@ -877,7 +877,7 @@ static void test_user_memory(void)
ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
IDirect3DTexture9_Release(texture2);
IDirect3DTexture9_Release(texture);
HeapFree(GetProcessHeap(), 0, mem);
free(mem);
refcount = IDirect3DDevice9Ex_Release(device);
ok(!refcount, "Device has %lu references left.\n", refcount);
@ -942,7 +942,7 @@ static void test_reset(void)
IDirect3D9_GetAdapterDisplayMode(d3d9, D3DADAPTER_DEFAULT, &d3ddm);
adapter_mode_count = IDirect3D9_GetAdapterModeCount(d3d9, D3DADAPTER_DEFAULT, d3ddm.Format);
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;
@ -1410,7 +1410,7 @@ static void test_reset(void)
d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8;
cleanup:
HeapFree(GetProcessHeap(), 0, modes);
free(modes);
IDirect3D9_Release(d3d9);
refcount = IDirect3DDevice9Ex_Release(device);
ok(!refcount, "Device has %lu references left.\n", refcount);
@ -1456,7 +1456,7 @@ static void test_reset_ex(void)
mode_filter.Size = sizeof(mode_filter);
mode_filter.Format = mode.Format;
adapter_mode_count = IDirect3D9Ex_GetAdapterModeCountEx(d3d9, D3DADAPTER_DEFAULT, &mode_filter);
modes = HeapAlloc(GetProcessHeap(), 0, sizeof(*modes) * adapter_mode_count);
modes = malloc(sizeof(*modes) * adapter_mode_count);
for (i = 0; i < adapter_mode_count; ++i)
{
unsigned int j;
@ -1833,7 +1833,7 @@ static void test_reset_ex(void)
IDirect3DSwapChain9_Release(swapchain);
cleanup:
HeapFree(GetProcessHeap(), 0, modes);
free(modes);
IDirect3D9Ex_Release(d3d9);
refcount = IDirect3DDevice9Ex_Release(device);
ok(!refcount, "Device has %lu references left.\n", refcount);
@ -1975,7 +1975,7 @@ static void test_user_memory_getdc(void)
goto done;
}
data = HeapAlloc(GetProcessHeap(), 0, sizeof(*data) * 16 * 16);
data = malloc(sizeof(*data) * 16 * 16);
memset(data, 0xaa, sizeof(*data) * 16 * 16);
hr = IDirect3DDevice9Ex_CreateOffscreenPlainSurface(device, 16, 16,
D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &surface, (HANDLE *)&data);
@ -1997,7 +1997,7 @@ static void test_user_memory_getdc(void)
ok(data[8 * 16] == 0x00000000, "Expected color 0x00000000, got %#x.\n", data[8 * 16]);
IDirect3DSurface9_Release(surface);
HeapFree(GetProcessHeap(), 0, data);
free(data);
ref = IDirect3DDevice9_Release(device);
ok(!ref, "Unexpected refcount %lu.\n", ref);

View file

@ -25,7 +25,6 @@
#define COBJMACROS
#include <d3d9.h>
#include "utils.h"
#include "wine/heap.h"
struct vec3
{
@ -93,7 +92,7 @@ static BOOL compare_elements(IDirect3DVertexDeclaration9 *declaration, const D3D
hr = IDirect3DVertexDeclaration9_GetDeclaration(declaration, NULL, &element_count);
ok(SUCCEEDED(hr), "Failed to get declaration, hr %#lx.\n", hr);
elements = HeapAlloc(GetProcessHeap(), 0, element_count * sizeof(*elements));
elements = malloc(element_count * sizeof(*elements));
hr = IDirect3DVertexDeclaration9_GetDeclaration(declaration, elements, &element_count);
ok(SUCCEEDED(hr), "Failed to get declaration, hr %#lx.\n", hr);
@ -116,7 +115,7 @@ static BOOL compare_elements(IDirect3DVertexDeclaration9 *declaration, const D3D
}
}
HeapFree(GetProcessHeap(), 0, elements);
free(elements);
return equal;
}
@ -174,7 +173,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);
@ -190,9 +189,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;
@ -202,7 +201,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;
}
@ -457,7 +456,7 @@ static void test_get_declaration(void)
element_count, expected_element_count);
/* Also test the returned data. */
elements = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(simple_decl));
elements = calloc(1, sizeof(simple_decl));
element_count = 0x1337c0de;
hr = IDirect3DVertexDeclaration9_GetDeclaration(declaration, elements, &element_count);
@ -477,7 +476,7 @@ static void test_get_declaration(void)
ok(!memcmp(elements, simple_decl, element_count * sizeof(*elements)),
"Original and returned vertexdeclarations are not the same.\n");
HeapFree(GetProcessHeap(), 0, elements);
free(elements);
IDirect3DVertexDeclaration9_Release(declaration);
refcount = IDirect3DDevice9_Release(device);
ok(!refcount, "Device has %lu references left.\n", refcount);
@ -2042,7 +2041,7 @@ static void test_reset(void)
IDirect3D9_GetAdapterDisplayMode(d3d, D3DADAPTER_DEFAULT, &d3ddm);
adapter_mode_count = IDirect3D9_GetAdapterModeCount(d3d, D3DADAPTER_DEFAULT, d3ddm.Format);
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;
@ -2552,7 +2551,7 @@ static void test_reset(void)
if (surface) IDirect3DSurface9_Release(surface);
cleanup:
HeapFree(GetProcessHeap(), 0, modes);
free(modes);
if (device2)
{
ULONG refcount = IDirect3DDevice9_Release(device2);
@ -5852,7 +5851,7 @@ done:
IDirect3D9_Release(d3d9);
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)
@ -11074,7 +11073,7 @@ static void test_shared_handle(void)
hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
ok(SUCCEEDED(hr), "Failed to get caps, hr %#lx.\n", hr);
mem = HeapAlloc(GetProcessHeap(), 0, 128 * 128 * 4);
mem = malloc(128 * 128 * 4);
/* Windows XP returns E_NOTIMPL, Windows 7 returns INVALIDCALL, except for
* CreateVertexBuffer, where it returns NOTAVAILABLE. */
@ -11136,7 +11135,7 @@ static void test_shared_handle(void)
D3DMULTISAMPLE_NONE, 0, TRUE, &surface, &handle);
ok(hr == E_NOTIMPL || broken(hr == D3DERR_INVALIDCALL), "Got unexpected hr %#lx.\n", hr);
HeapFree(GetProcessHeap(), 0, mem);
free(mem);
refcount = IDirect3DDevice9_Release(device);
ok(!refcount, "Device has %lu references left.\n", refcount);
IDirect3D9_Release(d3d);

View file

@ -1606,7 +1606,7 @@ static HRESULT render_state_test_init(IDirect3DDevice9 *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 == NULL) return E_FAIL;
test->test_context = ctx;
@ -1649,7 +1649,7 @@ static HRESULT render_state_test_init(IDirect3DDevice9 *device, struct state_tes
static void render_state_test_cleanup(IDirect3DDevice9 *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)
@ -1839,14 +1839,14 @@ static void resource_default_data_init(struct resource_test_data *data, const st
data->vs = NULL;
data->ps = NULL;
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->stream_offset = 0;
data->stream_stride = 0;
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;
@ -1913,7 +1913,7 @@ static void resource_test_data_init(IDirect3DDevice9 *device,
D3DFMT_INDEX32, D3DPOOL_DEFAULT, &data->ib, NULL);
ok(SUCCEEDED(hr), "CreateIndexBuffer returned %#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 = IDirect3DDevice9_CreateVertexBuffer(device, 64, D3DUSAGE_DYNAMIC,
@ -1922,7 +1922,7 @@ static void resource_test_data_init(IDirect3DDevice9 *device,
}
data->stream_offset = 4;
data->stream_stride = 64;
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 = IDirect3DDevice9_CreateTexture(device, 64, 64, 0, 0,
@ -1940,14 +1940,14 @@ static void resource_poison_data_init(struct resource_test_data *data, const str
data->vs = (IDirect3DVertexShader9 *)poison++;
data->ps = (IDirect3DPixelShader9 *)poison++;
data->ib = (IDirect3DIndexBuffer9 *)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] = (IDirect3DVertexBuffer9 *)poison++;
}
data->stream_offset = 16;
data->stream_stride = 128;
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] = (IDirect3DTexture9 *)poison++;
@ -1959,7 +1959,7 @@ static HRESULT resource_test_init(IDirect3DDevice9 *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;
@ -2005,17 +2005,17 @@ static void resource_test_cleanup(IDirect3DDevice9 *device, struct state_test *t
IDirect3DBaseTexture9_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)

View file

@ -35,7 +35,6 @@
#define COBJMACROS
#include <d3d9.h>
#include "utils.h"
#include "wine/heap.h"
struct vec2
{
@ -1027,8 +1026,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)
@ -1130,8 +1129,8 @@ static void test_specular_lighting(void)
done:
IDirect3D9_Release(d3d);
DestroyWindow(window);
HeapFree(GetProcessHeap(), 0, indices);
HeapFree(GetProcessHeap(), 0, quad);
free(indices);
free(quad);
}
static void clear_test(void)
@ -17065,7 +17064,7 @@ static void fp_special_test(void)
if (vs_body[i].size > body_size) body_size = vs_body[i].size;
}
vs_code = HeapAlloc(GetProcessHeap(), 0, sizeof(vs_header) + body_size + sizeof(vs_footer));
vs_code = malloc(sizeof(vs_header) + body_size + sizeof(vs_footer));
memcpy(vs_code, vs_header, sizeof(vs_header));
for (i = 0; i < ARRAY_SIZE(vs_body); ++i)
@ -17107,7 +17106,7 @@ static void fp_special_test(void)
IDirect3DVertexShader9_Release(vs);
}
HeapFree(GetProcessHeap(), 0, vs_code);
free(vs_code);
hr = IDirect3DDevice9_SetPixelShader(device, NULL);
ok(SUCCEEDED(hr), "SetPixelShader failed, hr %#lx.\n", hr);
@ -26319,7 +26318,7 @@ static void test_nrm_instruction(void)
for (i = 0; i < ARRAY_SIZE(tests); ++i)
body_size = max(body_size, tests[i].body_size);
ps_code = heap_alloc(sizeof(ps_header) + body_size * sizeof(*ps_code) + sizeof(ps_footer));
ps_code = malloc(sizeof(ps_header) + body_size * sizeof(*ps_code) + sizeof(ps_footer));
memcpy(ps_code, ps_header, sizeof(ps_header));
hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, FALSE);
@ -26365,7 +26364,7 @@ static void test_nrm_instruction(void)
hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
heap_free(ps_code);
free(ps_code);
IDirect3DVertexShader9_Release(vertex_shader);
IDirect3DVertexDeclaration9_Release(vertex_declaration);
refcount = IDirect3DDevice9_Release(device);