Commit 9ba4c100 authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

d3dcompiler_43: Use CRT allocation functions.

parent 101bb94a
......@@ -1432,7 +1432,7 @@ static void gen_oldps_input(struct bwriter_shader *shader, uint32_t texcoords)
void create_vs10_parser(struct asm_parser *ret) {
TRACE_(parsed_shader)("vs_1_0\n");
ret->shader = d3dcompiler_alloc(sizeof(*ret->shader));
ret->shader = calloc(1, sizeof(*ret->shader));
if(!ret->shader) {
ERR("Failed to allocate memory for the shader\n");
set_parse_status(&ret->status, PARSE_ERR);
......@@ -1449,7 +1449,7 @@ void create_vs10_parser(struct asm_parser *ret) {
void create_vs11_parser(struct asm_parser *ret) {
TRACE_(parsed_shader)("vs_1_1\n");
ret->shader = d3dcompiler_alloc(sizeof(*ret->shader));
ret->shader = calloc(1, sizeof(*ret->shader));
if(!ret->shader) {
ERR("Failed to allocate memory for the shader\n");
set_parse_status(&ret->status, PARSE_ERR);
......@@ -1466,7 +1466,7 @@ void create_vs11_parser(struct asm_parser *ret) {
void create_vs20_parser(struct asm_parser *ret) {
TRACE_(parsed_shader)("vs_2_0\n");
ret->shader = d3dcompiler_alloc(sizeof(*ret->shader));
ret->shader = calloc(1, sizeof(*ret->shader));
if(!ret->shader) {
ERR("Failed to allocate memory for the shader\n");
set_parse_status(&ret->status, PARSE_ERR);
......@@ -1483,7 +1483,7 @@ void create_vs20_parser(struct asm_parser *ret) {
void create_vs2x_parser(struct asm_parser *ret) {
TRACE_(parsed_shader)("vs_2_x\n");
ret->shader = d3dcompiler_alloc(sizeof(*ret->shader));
ret->shader = calloc(1, sizeof(*ret->shader));
if(!ret->shader) {
ERR("Failed to allocate memory for the shader\n");
set_parse_status(&ret->status, PARSE_ERR);
......@@ -1500,7 +1500,7 @@ void create_vs2x_parser(struct asm_parser *ret) {
void create_vs30_parser(struct asm_parser *ret) {
TRACE_(parsed_shader)("vs_3_0\n");
ret->shader = d3dcompiler_alloc(sizeof(*ret->shader));
ret->shader = calloc(1, sizeof(*ret->shader));
if(!ret->shader) {
ERR("Failed to allocate memory for the shader\n");
set_parse_status(&ret->status, PARSE_ERR);
......@@ -1516,7 +1516,7 @@ void create_vs30_parser(struct asm_parser *ret) {
void create_ps10_parser(struct asm_parser *ret) {
TRACE_(parsed_shader)("ps_1_0\n");
ret->shader = d3dcompiler_alloc(sizeof(*ret->shader));
ret->shader = calloc(1, sizeof(*ret->shader));
if(!ret->shader) {
ERR("Failed to allocate memory for the shader\n");
set_parse_status(&ret->status, PARSE_ERR);
......@@ -1533,7 +1533,7 @@ void create_ps10_parser(struct asm_parser *ret) {
void create_ps11_parser(struct asm_parser *ret) {
TRACE_(parsed_shader)("ps_1_1\n");
ret->shader = d3dcompiler_alloc(sizeof(*ret->shader));
ret->shader = calloc(1, sizeof(*ret->shader));
if(!ret->shader) {
ERR("Failed to allocate memory for the shader\n");
set_parse_status(&ret->status, PARSE_ERR);
......@@ -1550,7 +1550,7 @@ void create_ps11_parser(struct asm_parser *ret) {
void create_ps12_parser(struct asm_parser *ret) {
TRACE_(parsed_shader)("ps_1_2\n");
ret->shader = d3dcompiler_alloc(sizeof(*ret->shader));
ret->shader = calloc(1, sizeof(*ret->shader));
if(!ret->shader) {
ERR("Failed to allocate memory for the shader\n");
set_parse_status(&ret->status, PARSE_ERR);
......@@ -1567,7 +1567,7 @@ void create_ps12_parser(struct asm_parser *ret) {
void create_ps13_parser(struct asm_parser *ret) {
TRACE_(parsed_shader)("ps_1_3\n");
ret->shader = d3dcompiler_alloc(sizeof(*ret->shader));
ret->shader = calloc(1, sizeof(*ret->shader));
if(!ret->shader) {
ERR("Failed to allocate memory for the shader\n");
set_parse_status(&ret->status, PARSE_ERR);
......@@ -1584,7 +1584,7 @@ void create_ps13_parser(struct asm_parser *ret) {
void create_ps14_parser(struct asm_parser *ret) {
TRACE_(parsed_shader)("ps_1_4\n");
ret->shader = d3dcompiler_alloc(sizeof(*ret->shader));
ret->shader = calloc(1, sizeof(*ret->shader));
if(!ret->shader) {
ERR("Failed to allocate memory for the shader\n");
set_parse_status(&ret->status, PARSE_ERR);
......@@ -1601,7 +1601,7 @@ void create_ps14_parser(struct asm_parser *ret) {
void create_ps20_parser(struct asm_parser *ret) {
TRACE_(parsed_shader)("ps_2_0\n");
ret->shader = d3dcompiler_alloc(sizeof(*ret->shader));
ret->shader = calloc(1, sizeof(*ret->shader));
if(!ret->shader) {
ERR("Failed to allocate memory for the shader\n");
set_parse_status(&ret->status, PARSE_ERR);
......@@ -1618,7 +1618,7 @@ void create_ps20_parser(struct asm_parser *ret) {
void create_ps2x_parser(struct asm_parser *ret) {
TRACE_(parsed_shader)("ps_2_x\n");
ret->shader = d3dcompiler_alloc(sizeof(*ret->shader));
ret->shader = calloc(1, sizeof(*ret->shader));
if(!ret->shader) {
ERR("Failed to allocate memory for the shader\n");
set_parse_status(&ret->status, PARSE_ERR);
......@@ -1635,7 +1635,7 @@ void create_ps2x_parser(struct asm_parser *ret) {
void create_ps30_parser(struct asm_parser *ret) {
TRACE_(parsed_shader)("ps_3_0\n");
ret->shader = d3dcompiler_alloc(sizeof(*ret->shader));
ret->shader = calloc(1, sizeof(*ret->shader));
if(!ret->shader) {
ERR("Failed to allocate memory for the shader\n");
set_parse_status(&ret->status, PARSE_ERR);
......
......@@ -49,7 +49,7 @@ static void set_rel_reg(struct shader_reg *reg, struct rel_reg *rel) {
if(!rel->has_rel_reg) {
reg->rel_reg = NULL;
} else {
reg->rel_reg = d3dcompiler_alloc(sizeof(*reg->rel_reg));
reg->rel_reg = calloc(1, sizeof(*reg->rel_reg));
if(!reg->rel_reg) {
return;
}
......@@ -1718,11 +1718,11 @@ struct bwriter_shader *parse_asm_shader(char **messages)
if (asm_ctx.messages.size)
{
/* Shrink the buffer to the used size */
*messages = d3dcompiler_realloc(asm_ctx.messages.string, asm_ctx.messages.size + 1);
*messages = realloc(asm_ctx.messages.string, asm_ctx.messages.size + 1);
if (!*messages)
{
ERR("Out of memory, no messages reported\n");
d3dcompiler_free(asm_ctx.messages.string);
free(asm_ctx.messages.string);
}
}
else
......@@ -1733,7 +1733,7 @@ struct bwriter_shader *parse_asm_shader(char **messages)
else
{
if (asm_ctx.messages.capacity)
d3dcompiler_free(asm_ctx.messages.string);
free(asm_ctx.messages.string);
}
return ret;
......
......@@ -76,8 +76,8 @@ static ULONG STDMETHODCALLTYPE d3dcompiler_blob_Release(ID3DBlob *iface)
if (!refcount)
{
HeapFree(GetProcessHeap(), 0, blob->data);
HeapFree(GetProcessHeap(), 0, blob);
free(blob->data);
free(blob);
}
return refcount;
......@@ -120,7 +120,7 @@ static HRESULT d3dcompiler_blob_init(struct d3dcompiler_blob *blob, SIZE_T data_
blob->refcount = 1;
blob->size = data_size;
blob->data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, data_size);
blob->data = calloc(1, data_size);
if (!blob->data)
{
ERR("Failed to allocate D3D blob data memory\n");
......@@ -143,7 +143,7 @@ HRESULT WINAPI D3DCreateBlob(SIZE_T data_size, ID3DBlob **blob)
return D3DERR_INVALIDCALL;
}
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
object = calloc(1, sizeof(*object));
if (!object)
return E_OUTOFMEMORY;
......@@ -151,7 +151,7 @@ HRESULT WINAPI D3DCreateBlob(SIZE_T data_size, ID3DBlob **blob)
if (FAILED(hr))
{
WARN("Failed to initialize blob, hr %#lx.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
free(object);
return hr;
}
......@@ -474,7 +474,7 @@ HRESULT WINAPI D3DReadFileToBlob(const WCHAR *filename, ID3DBlob **contents)
return HRESULT_FROM_WIN32(GetLastError());
}
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
{
CloseHandle(file);
return E_OUTOFMEMORY;
......@@ -484,7 +484,7 @@ HRESULT WINAPI D3DReadFileToBlob(const WCHAR *filename, ID3DBlob **contents)
{
WARN("Failed to initialise blob, hr %#lx.\n", hr);
CloseHandle(file);
heap_free(object);
free(object);
return hr;
}
......@@ -492,8 +492,8 @@ HRESULT WINAPI D3DReadFileToBlob(const WCHAR *filename, ID3DBlob **contents)
{
WARN("Failed to read file contents.\n");
CloseHandle(file);
heap_free(object->data);
heap_free(object);
free(object->data);
free(object);
return E_FAIL;
}
CloseHandle(file);
......
......@@ -45,7 +45,7 @@ static BOOL array_reserve(void **elements, unsigned int *capacity, unsigned int
if (new_capacity < count)
new_capacity = count;
if (!(new_elements = d3dcompiler_realloc(*elements, new_capacity * size)))
if (!(new_elements = realloc(*elements, new_capacity * size)))
{
ERR("Failed to allocate memory.\n");
return FALSE;
......@@ -71,17 +71,17 @@ static BOOL array_reserve(void **elements, unsigned int *capacity, unsigned int
* NULL in case of an allocation failure
*/
struct instruction *alloc_instr(unsigned int srcs) {
struct instruction *ret = d3dcompiler_alloc(sizeof(*ret));
struct instruction *ret = calloc(1, sizeof(*ret));
if(!ret) {
ERR("Failed to allocate memory for an instruction structure\n");
return NULL;
}
if(srcs) {
ret->src = d3dcompiler_alloc(srcs * sizeof(*ret->src));
ret->src = calloc(1, srcs * sizeof(*ret->src));
if(!ret->src) {
ERR("Failed to allocate memory for instruction registers\n");
d3dcompiler_free(ret);
free(ret);
return NULL;
}
ret->num_srcs = srcs;
......@@ -120,7 +120,7 @@ BOOL add_constF(struct bwriter_shader *shader, uint32_t reg, float x, float y, f
if (shader->num_cf)
{
struct constant **newarray;
newarray = d3dcompiler_realloc(shader->constF, sizeof(*shader->constF) * (shader->num_cf + 1));
newarray = realloc(shader->constF, sizeof(*shader->constF) * (shader->num_cf + 1));
if (!newarray)
{
ERR("Failed to grow the constants array\n");
......@@ -130,7 +130,7 @@ BOOL add_constF(struct bwriter_shader *shader, uint32_t reg, float x, float y, f
}
else
{
shader->constF = d3dcompiler_alloc(sizeof(*shader->constF));
shader->constF = calloc(1, sizeof(*shader->constF));
if (!shader->constF)
{
ERR("Failed to allocate the constants array\n");
......@@ -138,7 +138,7 @@ BOOL add_constF(struct bwriter_shader *shader, uint32_t reg, float x, float y, f
}
}
newconst = d3dcompiler_alloc(sizeof(*newconst));
newconst = calloc(1, sizeof(*newconst));
if (!newconst)
{
ERR("Failed to allocate a new constant\n");
......@@ -162,7 +162,7 @@ BOOL add_constI(struct bwriter_shader *shader, uint32_t reg, int x, int y, int z
if (shader->num_ci)
{
struct constant **newarray;
newarray = d3dcompiler_realloc(shader->constI, sizeof(*shader->constI) * (shader->num_ci + 1));
newarray = realloc(shader->constI, sizeof(*shader->constI) * (shader->num_ci + 1));
if (!newarray)
{
ERR("Failed to grow the constants array\n");
......@@ -172,7 +172,7 @@ BOOL add_constI(struct bwriter_shader *shader, uint32_t reg, int x, int y, int z
}
else
{
shader->constI = d3dcompiler_alloc(sizeof(*shader->constI));
shader->constI = calloc(1, sizeof(*shader->constI));
if (!shader->constI)
{
ERR("Failed to allocate the constants array\n");
......@@ -180,7 +180,7 @@ BOOL add_constI(struct bwriter_shader *shader, uint32_t reg, int x, int y, int z
}
}
newconst = d3dcompiler_alloc(sizeof(*newconst));
newconst = calloc(1, sizeof(*newconst));
if (!newconst)
{
ERR("Failed to allocate a new constant\n");
......@@ -204,7 +204,7 @@ BOOL add_constB(struct bwriter_shader *shader, uint32_t reg, BOOL x)
if (shader->num_cb)
{
struct constant **newarray;
newarray = d3dcompiler_realloc(shader->constB, sizeof(*shader->constB) * (shader->num_cb + 1));
newarray = realloc(shader->constB, sizeof(*shader->constB) * (shader->num_cb + 1));
if (!newarray)
{
ERR("Failed to grow the constants array\n");
......@@ -214,7 +214,7 @@ BOOL add_constB(struct bwriter_shader *shader, uint32_t reg, BOOL x)
}
else
{
shader->constB = d3dcompiler_alloc(sizeof(*shader->constB));
shader->constB = calloc(1, sizeof(*shader->constB));
if (!shader->constB)
{
ERR("Failed to allocate the constants array\n");
......@@ -222,7 +222,7 @@ BOOL add_constB(struct bwriter_shader *shader, uint32_t reg, BOOL x)
}
}
newconst = d3dcompiler_alloc(sizeof(*newconst));
newconst = calloc(1, sizeof(*newconst));
if (!newconst)
{
ERR("Failed to allocate a new constant\n");
......@@ -258,7 +258,7 @@ BOOL record_declaration(struct bwriter_shader *shader, uint32_t usage, uint32_t
if (*num == 0)
{
*decl = d3dcompiler_alloc(sizeof(**decl));
*decl = calloc(1, sizeof(**decl));
if (!*decl)
{
ERR("Error allocating declarations array\n");
......@@ -276,8 +276,7 @@ BOOL record_declaration(struct bwriter_shader *shader, uint32_t usage, uint32_t
regnum, (*decl)[i].writemask & writemask);
}
newdecl = d3dcompiler_realloc(*decl,
sizeof(**decl) * ((*num) + 1));
newdecl = realloc(*decl, sizeof(**decl) * ((*num) + 1));
if (!newdecl)
{
ERR("Error reallocating declarations array\n");
......@@ -304,7 +303,7 @@ BOOL record_sampler(struct bwriter_shader *shader, uint32_t samptype, uint32_t m
if (shader->num_samplers == 0)
{
shader->samplers = d3dcompiler_alloc(sizeof(*shader->samplers));
shader->samplers = calloc(1, sizeof(*shader->samplers));
if (!shader->samplers)
{
ERR("Error allocating samplers array\n");
......@@ -325,7 +324,7 @@ BOOL record_sampler(struct bwriter_shader *shader, uint32_t samptype, uint32_t m
}
}
newarray = d3dcompiler_realloc(shader->samplers, sizeof(*shader->samplers) * (shader->num_samplers + 1));
newarray = realloc(shader->samplers, sizeof(*shader->samplers) * (shader->num_samplers + 1));
if (!newarray)
{
ERR("Error reallocating samplers array\n");
......@@ -397,7 +396,7 @@ struct bc_writer
static struct bytecode_buffer *allocate_buffer(void) {
struct bytecode_buffer *ret;
ret = d3dcompiler_alloc(sizeof(*ret));
ret = calloc(1, sizeof(*ret));
if(!ret) return NULL;
ret->state = S_OK;
return ret;
......@@ -2489,7 +2488,7 @@ HRESULT shader_write_bytecode(const struct bwriter_shader *shader, uint32_t **re
return E_FAIL;
}
if (!(writer = d3dcompiler_alloc(sizeof(*writer))))
if (!(writer = calloc(1, sizeof(*writer))))
return E_OUTOFMEMORY;
for (i = 0; i < ARRAY_SIZE(shader_backends); ++i)
......@@ -2507,7 +2506,7 @@ HRESULT shader_write_bytecode(const struct bwriter_shader *shader, uint32_t **re
{
FIXME("Unsupported shader type %#x, version %u.%u.\n",
shader->type, shader->major_version, shader->minor_version);
d3dcompiler_free(writer);
free(writer);
return E_NOTIMPL;
}
......@@ -2556,10 +2555,10 @@ HRESULT shader_write_bytecode(const struct bwriter_shader *shader, uint32_t **re
error:
if(buffer) {
d3dcompiler_free(buffer->data);
d3dcompiler_free(buffer);
free(buffer->data);
free(buffer);
}
d3dcompiler_free(writer);
free(writer);
return hr;
}
......@@ -2569,31 +2568,31 @@ void SlDeleteShader(struct bwriter_shader *shader) {
TRACE("Deleting shader %p\n", shader);
for(i = 0; i < shader->num_cf; i++) {
d3dcompiler_free(shader->constF[i]);
free(shader->constF[i]);
}
d3dcompiler_free(shader->constF);
free(shader->constF);
for(i = 0; i < shader->num_ci; i++) {
d3dcompiler_free(shader->constI[i]);
free(shader->constI[i]);
}
d3dcompiler_free(shader->constI);
free(shader->constI);
for(i = 0; i < shader->num_cb; i++) {
d3dcompiler_free(shader->constB[i]);
free(shader->constB[i]);
}
d3dcompiler_free(shader->constB);
free(shader->constB);
d3dcompiler_free(shader->inputs);
d3dcompiler_free(shader->outputs);
d3dcompiler_free(shader->samplers);
free(shader->inputs);
free(shader->outputs);
free(shader->samplers);
for(i = 0; i < shader->num_instrs; i++) {
for(j = 0; j < shader->instr[i]->num_srcs; j++) {
d3dcompiler_free(shader->instr[i]->src[j].rel_reg);
free(shader->instr[i]->src[j].rel_reg);
}
d3dcompiler_free(shader->instr[i]->src);
d3dcompiler_free(shader->instr[i]->dst.rel_reg);
d3dcompiler_free(shader->instr[i]);
free(shader->instr[i]->src);
free(shader->instr[i]->dst.rel_reg);
free(shader->instr[i]);
}
d3dcompiler_free(shader->instr);
free(shader->instr);
d3dcompiler_free(shader);
free(shader);
}
......@@ -98,7 +98,7 @@ static HRESULT WINAPI d3dcompiler_include_from_file_open(ID3DInclude *iface, D3D
len++;
initial_dir = current_dir;
}
fullpath = heap_alloc(len + strlen(filename) + 1);
fullpath = malloc(len + strlen(filename) + 1);
if (!fullpath)
return E_OUTOFMEMORY;
memcpy(fullpath, initial_dir, len);
......@@ -113,7 +113,7 @@ static HRESULT WINAPI d3dcompiler_include_from_file_open(ID3DInclude *iface, D3D
size = GetFileSize(file, NULL);
if (size == INVALID_FILE_SIZE)
goto error;
buffer = heap_alloc(size);
buffer = malloc(size);
if (!buffer)
goto error;
if (!ReadFile(file, buffer, size, &read, NULL) || read != size)
......@@ -122,13 +122,13 @@ static HRESULT WINAPI d3dcompiler_include_from_file_open(ID3DInclude *iface, D3D
*bytes = size;
*data = buffer;
heap_free(fullpath);
free(fullpath);
CloseHandle(file);
return S_OK;
error:
heap_free(fullpath);
heap_free(buffer);
free(fullpath);
free(buffer);
CloseHandle(file);
WARN("Returning E_FAIL.\n");
return E_FAIL;
......@@ -136,7 +136,7 @@ error:
static HRESULT WINAPI d3dcompiler_include_from_file_close(ID3DInclude *iface, const void *data)
{
heap_free((void *)data);
free((void *)data);
return S_OK;
}
......@@ -309,7 +309,7 @@ static HRESULT assemble_shader(const char *preproc_shader, ID3DBlob **shader_blo
hr = D3DCreateBlob(size, &buffer);
if (FAILED(hr))
{
HeapFree(GetProcessHeap(), 0, messages);
free(messages);
if (shader) SlDeleteShader(shader);
return hr;
}
......@@ -324,7 +324,7 @@ static HRESULT assemble_shader(const char *preproc_shader, ID3DBlob **shader_blo
if (*error_messages) ID3D10Blob_Release(*error_messages);
*error_messages = buffer;
}
HeapFree(GetProcessHeap(), 0, messages);
free(messages);
}
if (shader == NULL)
......@@ -346,14 +346,14 @@ static HRESULT assemble_shader(const char *preproc_shader, ID3DBlob **shader_blo
hr = D3DCreateBlob(size, &buffer);
if (FAILED(hr))
{
HeapFree(GetProcessHeap(), 0, res);
free(res);
return hr;
}
CopyMemory(ID3D10Blob_GetBufferPointer(buffer), res, size);
*shader_blob = buffer;
}
HeapFree(GetProcessHeap(), 0, res);
free(res);
return S_OK;
}
......@@ -711,7 +711,7 @@ HRESULT WINAPI D3DCompileFromFile(const WCHAR *filename, const D3D_SHADER_MACRO
goto end;
}
if (!(source = heap_alloc(source_size)))
if (!(source = malloc(source_size)))
{
hr = E_OUTOFMEMORY;
goto end;
......@@ -730,7 +730,7 @@ HRESULT WINAPI D3DCompileFromFile(const WCHAR *filename, const D3D_SHADER_MACRO
flags1, flags2, code, errors);
end:
heap_free(source);
free(source);
CloseHandle(file);
return hr;
}
......
......@@ -25,7 +25,6 @@
#include "wine/debug.h"
#include "wine/list.h"
#include "wine/rbtree.h"
#include "wine/heap.h"
#define COBJMACROS
#include "windef.h"
......@@ -153,23 +152,6 @@ struct bwriter_shader
unsigned int num_instrs, instr_alloc_size;
};
static inline void *d3dcompiler_alloc(SIZE_T size)
{
return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
}
static inline void *d3dcompiler_realloc(void *ptr, SIZE_T size)
{
if (!ptr)
return d3dcompiler_alloc(size);
return HeapReAlloc(GetProcessHeap(), 0, ptr, size);
}
static inline BOOL d3dcompiler_free(void *ptr)
{
return HeapFree(GetProcessHeap(), 0, ptr);
}
struct asm_parser;
/* This structure is only used in asmshader.y, but since the .l file accesses the semantic types
......
......@@ -203,25 +203,15 @@ static struct d3dcompiler_shader_reflection_variable null_variable =
static BOOL copy_name(const char *ptr, char **name)
{
size_t name_len;
if (!ptr || !ptr[0]) return TRUE;
if (!ptr) return TRUE;
name_len = strlen(ptr) + 1;
if (name_len == 1)
{
return TRUE;
}
*name = HeapAlloc(GetProcessHeap(), 0, name_len);
*name = strdup(ptr);
if (!*name)
{
ERR("Failed to allocate name memory.\n");
return FALSE;
}
memcpy(*name, ptr, name_len);
return TRUE;
}
......@@ -229,7 +219,7 @@ static BOOL copy_value(const char *ptr, void **value, uint32_t size)
{
if (!ptr || !size) return TRUE;
*value = HeapAlloc(GetProcessHeap(), 0, size);
*value = malloc(size);
if (!*value)
{
ERR("Failed to allocate value memory.\n");
......@@ -253,7 +243,7 @@ static void free_type_member(struct d3dcompiler_shader_reflection_type_member *m
{
if (member)
{
HeapFree(GetProcessHeap(), 0, member->name);
free(member->name);
}
}
......@@ -270,27 +260,27 @@ static void d3dcompiler_shader_reflection_type_destroy(struct wine_rb_entry *ent
{
free_type_member(&t->members[i]);
}
HeapFree(GetProcessHeap(), 0, t->members);
free(t->members);
}
heap_free(t->name);
HeapFree(GetProcessHeap(), 0, t);
free(t->name);
free(t);
}
static void free_signature(struct d3dcompiler_shader_signature *sig)
{
TRACE("Free signature %p\n", sig);
HeapFree(GetProcessHeap(), 0, sig->elements);
HeapFree(GetProcessHeap(), 0, sig->string_data);
free(sig->elements);
free(sig->string_data);
}
static void free_variable(struct d3dcompiler_shader_reflection_variable *var)
{
if (var)
{
HeapFree(GetProcessHeap(), 0, var->name);
HeapFree(GetProcessHeap(), 0, var->default_value);
free(var->name);
free(var->default_value);
}
}
......@@ -304,10 +294,10 @@ static void free_constant_buffer(struct d3dcompiler_shader_reflection_constant_b
{
free_variable(&cb->variables[i]);
}
HeapFree(GetProcessHeap(), 0, cb->variables);
free(cb->variables);
}
HeapFree(GetProcessHeap(), 0, cb->name);
free(cb->name);
}
static void reflection_cleanup(struct d3dcompiler_shader_reflection *ref)
......@@ -317,19 +307,19 @@ static void reflection_cleanup(struct d3dcompiler_shader_reflection *ref)
if (ref->isgn)
{
free_signature(ref->isgn);
HeapFree(GetProcessHeap(), 0, ref->isgn);
free(ref->isgn);
}
if (ref->osgn)
{
free_signature(ref->osgn);
HeapFree(GetProcessHeap(), 0, ref->osgn);
free(ref->osgn);
}
if (ref->pcsg)
{
free_signature(ref->pcsg);
HeapFree(GetProcessHeap(), 0, ref->pcsg);
free(ref->pcsg);
}
if (ref->constant_buffers)
......@@ -343,10 +333,10 @@ static void reflection_cleanup(struct d3dcompiler_shader_reflection *ref)
}
wine_rb_destroy(&ref->types, d3dcompiler_shader_reflection_type_destroy, NULL);
HeapFree(GetProcessHeap(), 0, ref->constant_buffers);
HeapFree(GetProcessHeap(), 0, ref->bound_resources);
HeapFree(GetProcessHeap(), 0, ref->resource_string);
HeapFree(GetProcessHeap(), 0, ref->creator);
free(ref->constant_buffers);
free(ref->bound_resources);
free(ref->resource_string);
free(ref->creator);
}
/* IUnknown methods */
......@@ -395,7 +385,7 @@ static ULONG STDMETHODCALLTYPE d3dcompiler_shader_reflection_Release(ID3D11Shade
if (!refcount)
{
reflection_cleanup(This);
HeapFree(GetProcessHeap(), 0, This);
free(This);
}
return refcount;
......@@ -1270,7 +1260,7 @@ static HRESULT d3dcompiler_parse_type_members(struct d3dcompiler_shader_reflecti
if (!member->type)
{
ERR("Failed to get member type\n");
HeapFree(GetProcessHeap(), 0, member->name);
free(member->name);
return E_FAIL;
}
......@@ -1318,7 +1308,7 @@ static HRESULT d3dcompiler_parse_type(struct d3dcompiler_shader_reflection_type
{
const char *ptr2 = data + member_offset;
members = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*members) * desc->Members);
members = calloc(desc->Members, sizeof(*members));
if (!members)
{
ERR("Failed to allocate type memory.\n");
......@@ -1343,7 +1333,7 @@ static HRESULT d3dcompiler_parse_type(struct d3dcompiler_shader_reflection_type
if (!copy_name(data + offset, &type->name))
{
ERR("Failed to copy name.\n");
heap_free(members);
free(members);
return E_OUTOFMEMORY;
}
desc->Name = type->name;
......@@ -1360,7 +1350,7 @@ err_out:
{
free_type_member(&members[i]);
}
HeapFree(GetProcessHeap(), 0, members);
free(members);
return hr;
}
......@@ -1377,7 +1367,7 @@ static struct d3dcompiler_shader_reflection_type *get_reflection_type(struct d3d
return WINE_RB_ENTRY_VALUE(entry, struct d3dcompiler_shader_reflection_type, entry);
}
type = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*type));
type = calloc(1, sizeof(*type));
if (!type)
return NULL;
......@@ -1389,14 +1379,14 @@ static struct d3dcompiler_shader_reflection_type *get_reflection_type(struct d3d
if (FAILED(hr))
{
ERR("Failed to parse type info, hr %#lx.\n", hr);
HeapFree(GetProcessHeap(), 0, type);
free(type);
return NULL;
}
if (wine_rb_put(&reflection->types, &offset, &type->entry) == -1)
{
ERR("Failed to insert type entry.\n");
HeapFree(GetProcessHeap(), 0, type);
free(type);
return NULL;
}
......@@ -1410,7 +1400,7 @@ static HRESULT d3dcompiler_parse_variables(struct d3dcompiler_shader_reflection_
unsigned int i;
HRESULT hr;
variables = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cb->variable_count * sizeof(*variables));
variables = calloc(cb->variable_count, sizeof(*variables));
if (!variables)
{
ERR("Failed to allocate variables memory.\n");
......@@ -1475,7 +1465,7 @@ err_out:
{
free_variable(&variables[i]);
}
HeapFree(GetProcessHeap(), 0, variables);
free(variables);
return hr;
}
......@@ -1548,7 +1538,7 @@ static HRESULT d3dcompiler_parse_rdef(struct d3dcompiler_shader_reflection *r, c
string_data_offset = resource_offset + r->bound_resource_count * 8 * sizeof(uint32_t);
string_data_size = (cbuffer_offset ? cbuffer_offset : creator_offset) - string_data_offset;
string_data = HeapAlloc(GetProcessHeap(), 0, string_data_size);
string_data = malloc(string_data_size);
if (!string_data)
{
ERR("Failed to allocate string data memory.\n");
......@@ -1557,7 +1547,7 @@ static HRESULT d3dcompiler_parse_rdef(struct d3dcompiler_shader_reflection *r, c
}
memcpy(string_data, data + string_data_offset, string_data_size);
bound_resources = HeapAlloc(GetProcessHeap(), 0, r->bound_resource_count * sizeof(*bound_resources));
bound_resources = calloc(r->bound_resource_count, sizeof(*bound_resources));
if (!bound_resources)
{
ERR("Failed to allocate resources memory.\n");
......@@ -1604,7 +1594,6 @@ static HRESULT d3dcompiler_parse_rdef(struct d3dcompiler_shader_reflection *r, c
}
else
{
desc->Space = 0;
desc->uID = desc->BindPoint;
}
}
......@@ -1612,7 +1601,7 @@ static HRESULT d3dcompiler_parse_rdef(struct d3dcompiler_shader_reflection *r, c
if (r->constant_buffer_count)
{
constant_buffers = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, r->constant_buffer_count * sizeof(*constant_buffers));
constant_buffers = calloc(r->constant_buffer_count, sizeof(*constant_buffers));
if (!constant_buffers)
{
ERR("Failed to allocate constant buffer memory.\n");
......@@ -1673,10 +1662,10 @@ err_out:
{
free_constant_buffer(&constant_buffers[i]);
}
HeapFree(GetProcessHeap(), 0, constant_buffers);
HeapFree(GetProcessHeap(), 0, bound_resources);
HeapFree(GetProcessHeap(), 0, string_data);
HeapFree(GetProcessHeap(), 0, creator);
free(constant_buffers);
free(bound_resources);
free(string_data);
free(creator);
return hr;
}
......@@ -1715,7 +1704,7 @@ static HRESULT d3dcompiler_parse_signature(struct d3dcompiler_shader_signature *
skip_u32_unknown(&ptr, 1);
d = HeapAlloc(GetProcessHeap(), 0, count * sizeof(*d));
d = calloc(count, sizeof(*d));
if (!d)
{
ERR("Failed to allocate signature memory.\n");
......@@ -1726,11 +1715,11 @@ static HRESULT d3dcompiler_parse_signature(struct d3dcompiler_shader_signature *
string_data_offset = 2 * sizeof(uint32_t) + count * element_size * sizeof(uint32_t);
string_data_size = section->data.size - string_data_offset;
string_data = HeapAlloc(GetProcessHeap(), 0, string_data_size);
string_data = malloc(string_data_size);
if (!string_data)
{
ERR("Failed to allocate string data memory.\n");
HeapFree(GetProcessHeap(), 0, d);
free(d);
return E_OUTOFMEMORY;
}
memcpy(string_data, (const char *)section->data.code + string_data_offset, string_data_size);
......@@ -1748,10 +1737,6 @@ static HRESULT d3dcompiler_parse_signature(struct d3dcompiler_shader_signature *
{
d[i].Stream = read_u32(&ptr);
}
else
{
d[i].Stream = 0;
}
#endif
name_offset = read_u32(&ptr);
......@@ -1892,7 +1877,7 @@ static HRESULT d3dcompiler_shader_reflection_init(struct d3dcompiler_shader_refl
break;
case TAG_ISGN:
reflection->isgn = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*reflection->isgn));
reflection->isgn = calloc(1, sizeof(*reflection->isgn));
if (!reflection->isgn)
{
ERR("Failed to allocate ISGN memory.\n");
......@@ -1910,7 +1895,7 @@ static HRESULT d3dcompiler_shader_reflection_init(struct d3dcompiler_shader_refl
case TAG_OSG5:
case TAG_OSGN:
reflection->osgn = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*reflection->osgn));
reflection->osgn = calloc(1, sizeof(*reflection->osgn));
if (!reflection->osgn)
{
ERR("Failed to allocate OSGN memory.\n");
......@@ -1927,7 +1912,7 @@ static HRESULT d3dcompiler_shader_reflection_init(struct d3dcompiler_shader_refl
break;
case TAG_PCSG:
reflection->pcsg = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*reflection->pcsg));
reflection->pcsg = calloc(1, sizeof(*reflection->pcsg));
if (!reflection->pcsg)
{
ERR("Failed to allocate PCSG memory.\n");
......@@ -1988,7 +1973,7 @@ HRESULT WINAPI D3D10ReflectShader(const void *data, SIZE_T data_size, ID3D10Shad
TRACE("data %p, data_size %Iu, reflector %p.\n", data, data_size, reflector);
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
{
ERR("Failed to allocate D3D10 shader reflection object memory.\n");
return E_OUTOFMEMORY;
......@@ -2002,7 +1987,7 @@ HRESULT WINAPI D3D10ReflectShader(const void *data, SIZE_T data_size, ID3D10Shad
if (FAILED(hr))
{
WARN("Failed to initialize shader reflection.\n");
HeapFree(GetProcessHeap(), 0, object);
free(object);
return hr;
}
......@@ -2048,7 +2033,7 @@ HRESULT WINAPI D3DReflect(const void *data, SIZE_T data_size, REFIID riid, void
#endif
}
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
object = calloc(1, sizeof(*object));
if (!object)
return E_OUTOFMEMORY;
......@@ -2061,7 +2046,7 @@ HRESULT WINAPI D3DReflect(const void *data, SIZE_T data_size, REFIID riid, void
if (FAILED(hr))
{
WARN("Failed to initialize shader reflection\n");
HeapFree(GetProcessHeap(), 0, object);
free(object);
return hr;
}
......
......@@ -533,7 +533,7 @@ void compilation_message(struct compilation_messages *msg, const char *fmt, va_l
if (msg->capacity == 0)
{
msg->string = d3dcompiler_alloc(MESSAGEBUFFER_INITIAL_SIZE);
msg->string = calloc(1, MESSAGEBUFFER_INITIAL_SIZE);
if (msg->string == NULL)
{
ERR("Error allocating memory for parser messages\n");
......@@ -550,7 +550,7 @@ void compilation_message(struct compilation_messages *msg, const char *fmt, va_l
if (rc < 0 || rc >= msg->capacity - msg->size)
{
size = msg->capacity * 2;
buffer = d3dcompiler_realloc(msg->string, size);
buffer = realloc(msg->string, size);
if (buffer == NULL)
{
ERR("Error reallocating memory for parser messages\n");
......
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