d3dcompiler: Rename asm_alloc/realloc/free functions to more generic names.

oldstable
Matteo Bruni 2012-05-08 16:17:32 +02:00 committed by Alexandre Julliard
parent e2866d6fa1
commit 491d0e9d6b
5 changed files with 77 additions and 67 deletions

View File

@ -1350,7 +1350,7 @@ static void gen_oldps_input(struct bwriter_shader *shader, DWORD texcoords) {
void create_vs10_parser(struct asm_parser *ret) { void create_vs10_parser(struct asm_parser *ret) {
TRACE_(parsed_shader)("vs_1_0\n"); TRACE_(parsed_shader)("vs_1_0\n");
ret->shader = asm_alloc(sizeof(*ret->shader)); ret->shader = d3dcompiler_alloc(sizeof(*ret->shader));
if(!ret->shader) { if(!ret->shader) {
ERR("Failed to allocate memory for the shader\n"); ERR("Failed to allocate memory for the shader\n");
set_parse_status(&ret->status, PARSE_ERR); set_parse_status(&ret->status, PARSE_ERR);
@ -1366,7 +1366,7 @@ void create_vs10_parser(struct asm_parser *ret) {
void create_vs11_parser(struct asm_parser *ret) { void create_vs11_parser(struct asm_parser *ret) {
TRACE_(parsed_shader)("vs_1_1\n"); TRACE_(parsed_shader)("vs_1_1\n");
ret->shader = asm_alloc(sizeof(*ret->shader)); ret->shader = d3dcompiler_alloc(sizeof(*ret->shader));
if(!ret->shader) { if(!ret->shader) {
ERR("Failed to allocate memory for the shader\n"); ERR("Failed to allocate memory for the shader\n");
set_parse_status(&ret->status, PARSE_ERR); set_parse_status(&ret->status, PARSE_ERR);
@ -1382,7 +1382,7 @@ void create_vs11_parser(struct asm_parser *ret) {
void create_vs20_parser(struct asm_parser *ret) { void create_vs20_parser(struct asm_parser *ret) {
TRACE_(parsed_shader)("vs_2_0\n"); TRACE_(parsed_shader)("vs_2_0\n");
ret->shader = asm_alloc(sizeof(*ret->shader)); ret->shader = d3dcompiler_alloc(sizeof(*ret->shader));
if(!ret->shader) { if(!ret->shader) {
ERR("Failed to allocate memory for the shader\n"); ERR("Failed to allocate memory for the shader\n");
set_parse_status(&ret->status, PARSE_ERR); set_parse_status(&ret->status, PARSE_ERR);
@ -1398,7 +1398,7 @@ void create_vs20_parser(struct asm_parser *ret) {
void create_vs2x_parser(struct asm_parser *ret) { void create_vs2x_parser(struct asm_parser *ret) {
TRACE_(parsed_shader)("vs_2_x\n"); TRACE_(parsed_shader)("vs_2_x\n");
ret->shader = asm_alloc(sizeof(*ret->shader)); ret->shader = d3dcompiler_alloc(sizeof(*ret->shader));
if(!ret->shader) { if(!ret->shader) {
ERR("Failed to allocate memory for the shader\n"); ERR("Failed to allocate memory for the shader\n");
set_parse_status(&ret->status, PARSE_ERR); set_parse_status(&ret->status, PARSE_ERR);
@ -1414,7 +1414,7 @@ void create_vs2x_parser(struct asm_parser *ret) {
void create_vs30_parser(struct asm_parser *ret) { void create_vs30_parser(struct asm_parser *ret) {
TRACE_(parsed_shader)("vs_3_0\n"); TRACE_(parsed_shader)("vs_3_0\n");
ret->shader = asm_alloc(sizeof(*ret->shader)); ret->shader = d3dcompiler_alloc(sizeof(*ret->shader));
if(!ret->shader) { if(!ret->shader) {
ERR("Failed to allocate memory for the shader\n"); ERR("Failed to allocate memory for the shader\n");
set_parse_status(&ret->status, PARSE_ERR); set_parse_status(&ret->status, PARSE_ERR);
@ -1429,7 +1429,7 @@ void create_vs30_parser(struct asm_parser *ret) {
void create_ps10_parser(struct asm_parser *ret) { void create_ps10_parser(struct asm_parser *ret) {
TRACE_(parsed_shader)("ps_1_0\n"); TRACE_(parsed_shader)("ps_1_0\n");
ret->shader = asm_alloc(sizeof(*ret->shader)); ret->shader = d3dcompiler_alloc(sizeof(*ret->shader));
if(!ret->shader) { if(!ret->shader) {
ERR("Failed to allocate memory for the shader\n"); ERR("Failed to allocate memory for the shader\n");
set_parse_status(&ret->status, PARSE_ERR); set_parse_status(&ret->status, PARSE_ERR);
@ -1445,7 +1445,7 @@ void create_ps10_parser(struct asm_parser *ret) {
void create_ps11_parser(struct asm_parser *ret) { void create_ps11_parser(struct asm_parser *ret) {
TRACE_(parsed_shader)("ps_1_1\n"); TRACE_(parsed_shader)("ps_1_1\n");
ret->shader = asm_alloc(sizeof(*ret->shader)); ret->shader = d3dcompiler_alloc(sizeof(*ret->shader));
if(!ret->shader) { if(!ret->shader) {
ERR("Failed to allocate memory for the shader\n"); ERR("Failed to allocate memory for the shader\n");
set_parse_status(&ret->status, PARSE_ERR); set_parse_status(&ret->status, PARSE_ERR);
@ -1461,7 +1461,7 @@ void create_ps11_parser(struct asm_parser *ret) {
void create_ps12_parser(struct asm_parser *ret) { void create_ps12_parser(struct asm_parser *ret) {
TRACE_(parsed_shader)("ps_1_2\n"); TRACE_(parsed_shader)("ps_1_2\n");
ret->shader = asm_alloc(sizeof(*ret->shader)); ret->shader = d3dcompiler_alloc(sizeof(*ret->shader));
if(!ret->shader) { if(!ret->shader) {
ERR("Failed to allocate memory for the shader\n"); ERR("Failed to allocate memory for the shader\n");
set_parse_status(&ret->status, PARSE_ERR); set_parse_status(&ret->status, PARSE_ERR);
@ -1477,7 +1477,7 @@ void create_ps12_parser(struct asm_parser *ret) {
void create_ps13_parser(struct asm_parser *ret) { void create_ps13_parser(struct asm_parser *ret) {
TRACE_(parsed_shader)("ps_1_3\n"); TRACE_(parsed_shader)("ps_1_3\n");
ret->shader = asm_alloc(sizeof(*ret->shader)); ret->shader = d3dcompiler_alloc(sizeof(*ret->shader));
if(!ret->shader) { if(!ret->shader) {
ERR("Failed to allocate memory for the shader\n"); ERR("Failed to allocate memory for the shader\n");
set_parse_status(&ret->status, PARSE_ERR); set_parse_status(&ret->status, PARSE_ERR);
@ -1493,7 +1493,7 @@ void create_ps13_parser(struct asm_parser *ret) {
void create_ps14_parser(struct asm_parser *ret) { void create_ps14_parser(struct asm_parser *ret) {
TRACE_(parsed_shader)("ps_1_4\n"); TRACE_(parsed_shader)("ps_1_4\n");
ret->shader = asm_alloc(sizeof(*ret->shader)); ret->shader = d3dcompiler_alloc(sizeof(*ret->shader));
if(!ret->shader) { if(!ret->shader) {
ERR("Failed to allocate memory for the shader\n"); ERR("Failed to allocate memory for the shader\n");
set_parse_status(&ret->status, PARSE_ERR); set_parse_status(&ret->status, PARSE_ERR);
@ -1509,7 +1509,7 @@ void create_ps14_parser(struct asm_parser *ret) {
void create_ps20_parser(struct asm_parser *ret) { void create_ps20_parser(struct asm_parser *ret) {
TRACE_(parsed_shader)("ps_2_0\n"); TRACE_(parsed_shader)("ps_2_0\n");
ret->shader = asm_alloc(sizeof(*ret->shader)); ret->shader = d3dcompiler_alloc(sizeof(*ret->shader));
if(!ret->shader) { if(!ret->shader) {
ERR("Failed to allocate memory for the shader\n"); ERR("Failed to allocate memory for the shader\n");
set_parse_status(&ret->status, PARSE_ERR); set_parse_status(&ret->status, PARSE_ERR);
@ -1525,7 +1525,7 @@ void create_ps20_parser(struct asm_parser *ret) {
void create_ps2x_parser(struct asm_parser *ret) { void create_ps2x_parser(struct asm_parser *ret) {
TRACE_(parsed_shader)("ps_2_x\n"); TRACE_(parsed_shader)("ps_2_x\n");
ret->shader = asm_alloc(sizeof(*ret->shader)); ret->shader = d3dcompiler_alloc(sizeof(*ret->shader));
if(!ret->shader) { if(!ret->shader) {
ERR("Failed to allocate memory for the shader\n"); ERR("Failed to allocate memory for the shader\n");
set_parse_status(&ret->status, PARSE_ERR); set_parse_status(&ret->status, PARSE_ERR);
@ -1541,7 +1541,7 @@ void create_ps2x_parser(struct asm_parser *ret) {
void create_ps30_parser(struct asm_parser *ret) { void create_ps30_parser(struct asm_parser *ret) {
TRACE_(parsed_shader)("ps_3_0\n"); TRACE_(parsed_shader)("ps_3_0\n");
ret->shader = asm_alloc(sizeof(*ret->shader)); ret->shader = d3dcompiler_alloc(sizeof(*ret->shader));
if(!ret->shader) { if(!ret->shader) {
ERR("Failed to allocate memory for the shader\n"); ERR("Failed to allocate memory for the shader\n");
set_parse_status(&ret->status, PARSE_ERR); set_parse_status(&ret->status, PARSE_ERR);

View File

@ -51,7 +51,7 @@ static void set_rel_reg(struct shader_reg *reg, struct rel_reg *rel) {
if(!rel->has_rel_reg) { if(!rel->has_rel_reg) {
reg->rel_reg = NULL; reg->rel_reg = NULL;
} else { } else {
reg->rel_reg = asm_alloc(sizeof(*reg->rel_reg)); reg->rel_reg = d3dcompiler_alloc(sizeof(*reg->rel_reg));
if(!reg->rel_reg) { if(!reg->rel_reg) {
return; return;
} }
@ -1693,16 +1693,22 @@ struct bwriter_shader *parse_asm_shader(char **messages)
if (asm_ctx.messages.size) if (asm_ctx.messages.size)
{ {
/* Shrink the buffer to the used size */ /* Shrink the buffer to the used size */
*messages = asm_realloc(asm_ctx.messages.string, asm_ctx.messages.size + 1); *messages = d3dcompiler_realloc(asm_ctx.messages.string, asm_ctx.messages.size + 1);
if(!*messages) { if (!*messages)
{
ERR("Out of memory, no messages reported\n"); ERR("Out of memory, no messages reported\n");
asm_free(asm_ctx.messages.string); d3dcompiler_free(asm_ctx.messages.string);
} }
} else { }
else
{
*messages = NULL; *messages = NULL;
} }
} else { }
if(asm_ctx.messages.capacity) asm_free(asm_ctx.messages.string); else
{
if (asm_ctx.messages.capacity)
d3dcompiler_free(asm_ctx.messages.string);
} }
return ret; return ret;

View File

@ -44,17 +44,17 @@ WINE_DEFAULT_DEBUG_CHANNEL(asmshader);
* NULL in case of an allocation failure * NULL in case of an allocation failure
*/ */
struct instruction *alloc_instr(unsigned int srcs) { struct instruction *alloc_instr(unsigned int srcs) {
struct instruction *ret = asm_alloc(sizeof(*ret)); struct instruction *ret = d3dcompiler_alloc(sizeof(*ret));
if(!ret) { if(!ret) {
ERR("Failed to allocate memory for an instruction structure\n"); ERR("Failed to allocate memory for an instruction structure\n");
return NULL; return NULL;
} }
if(srcs) { if(srcs) {
ret->src = asm_alloc(srcs * sizeof(*ret->src)); ret->src = d3dcompiler_alloc(srcs * sizeof(*ret->src));
if(!ret->src) { if(!ret->src) {
ERR("Failed to allocate memory for instruction registers\n"); ERR("Failed to allocate memory for instruction registers\n");
asm_free(ret); d3dcompiler_free(ret);
return NULL; return NULL;
} }
ret->num_srcs = srcs; ret->num_srcs = srcs;
@ -80,14 +80,14 @@ BOOL add_instruction(struct bwriter_shader *shader, struct instruction *instr) {
if(!shader) return FALSE; if(!shader) return FALSE;
if(shader->instr_alloc_size == 0) { if(shader->instr_alloc_size == 0) {
shader->instr = asm_alloc(sizeof(*shader->instr) * INSTRARRAY_INITIAL_SIZE); shader->instr = d3dcompiler_alloc(sizeof(*shader->instr) * INSTRARRAY_INITIAL_SIZE);
if(!shader->instr) { if(!shader->instr) {
ERR("Failed to allocate the shader instruction array\n"); ERR("Failed to allocate the shader instruction array\n");
return FALSE; return FALSE;
} }
shader->instr_alloc_size = INSTRARRAY_INITIAL_SIZE; shader->instr_alloc_size = INSTRARRAY_INITIAL_SIZE;
} else if(shader->instr_alloc_size == shader->num_instrs) { } else if(shader->instr_alloc_size == shader->num_instrs) {
new_instructions = asm_realloc(shader->instr, new_instructions = d3dcompiler_realloc(shader->instr,
sizeof(*shader->instr) * (shader->instr_alloc_size) * 2); sizeof(*shader->instr) * (shader->instr_alloc_size) * 2);
if(!new_instructions) { if(!new_instructions) {
ERR("Failed to grow the shader instruction array\n"); ERR("Failed to grow the shader instruction array\n");
@ -110,7 +110,7 @@ BOOL add_constF(struct bwriter_shader *shader, DWORD reg, float x, float y, floa
if(shader->num_cf) { if(shader->num_cf) {
struct constant **newarray; struct constant **newarray;
newarray = asm_realloc(shader->constF, newarray = d3dcompiler_realloc(shader->constF,
sizeof(*shader->constF) * (shader->num_cf + 1)); sizeof(*shader->constF) * (shader->num_cf + 1));
if(!newarray) { if(!newarray) {
ERR("Failed to grow the constants array\n"); ERR("Failed to grow the constants array\n");
@ -118,14 +118,14 @@ BOOL add_constF(struct bwriter_shader *shader, DWORD reg, float x, float y, floa
} }
shader->constF = newarray; shader->constF = newarray;
} else { } else {
shader->constF = asm_alloc(sizeof(*shader->constF)); shader->constF = d3dcompiler_alloc(sizeof(*shader->constF));
if(!shader->constF) { if(!shader->constF) {
ERR("Failed to allocate the constants array\n"); ERR("Failed to allocate the constants array\n");
return FALSE; return FALSE;
} }
} }
newconst = asm_alloc(sizeof(*newconst)); newconst = d3dcompiler_alloc(sizeof(*newconst));
if(!newconst) { if(!newconst) {
ERR("Failed to allocate a new constant\n"); ERR("Failed to allocate a new constant\n");
return FALSE; return FALSE;
@ -146,7 +146,7 @@ BOOL add_constI(struct bwriter_shader *shader, DWORD reg, INT x, INT y, INT z, I
if(shader->num_ci) { if(shader->num_ci) {
struct constant **newarray; struct constant **newarray;
newarray = asm_realloc(shader->constI, newarray = d3dcompiler_realloc(shader->constI,
sizeof(*shader->constI) * (shader->num_ci + 1)); sizeof(*shader->constI) * (shader->num_ci + 1));
if(!newarray) { if(!newarray) {
ERR("Failed to grow the constants array\n"); ERR("Failed to grow the constants array\n");
@ -154,14 +154,14 @@ BOOL add_constI(struct bwriter_shader *shader, DWORD reg, INT x, INT y, INT z, I
} }
shader->constI = newarray; shader->constI = newarray;
} else { } else {
shader->constI = asm_alloc(sizeof(*shader->constI)); shader->constI = d3dcompiler_alloc(sizeof(*shader->constI));
if(!shader->constI) { if(!shader->constI) {
ERR("Failed to allocate the constants array\n"); ERR("Failed to allocate the constants array\n");
return FALSE; return FALSE;
} }
} }
newconst = asm_alloc(sizeof(*newconst)); newconst = d3dcompiler_alloc(sizeof(*newconst));
if(!newconst) { if(!newconst) {
ERR("Failed to allocate a new constant\n"); ERR("Failed to allocate a new constant\n");
return FALSE; return FALSE;
@ -182,7 +182,7 @@ BOOL add_constB(struct bwriter_shader *shader, DWORD reg, BOOL x) {
if(shader->num_cb) { if(shader->num_cb) {
struct constant **newarray; struct constant **newarray;
newarray = asm_realloc(shader->constB, newarray = d3dcompiler_realloc(shader->constB,
sizeof(*shader->constB) * (shader->num_cb + 1)); sizeof(*shader->constB) * (shader->num_cb + 1));
if(!newarray) { if(!newarray) {
ERR("Failed to grow the constants array\n"); ERR("Failed to grow the constants array\n");
@ -190,14 +190,14 @@ BOOL add_constB(struct bwriter_shader *shader, DWORD reg, BOOL x) {
} }
shader->constB = newarray; shader->constB = newarray;
} else { } else {
shader->constB = asm_alloc(sizeof(*shader->constB)); shader->constB = d3dcompiler_alloc(sizeof(*shader->constB));
if(!shader->constB) { if(!shader->constB) {
ERR("Failed to allocate the constants array\n"); ERR("Failed to allocate the constants array\n");
return FALSE; return FALSE;
} }
} }
newconst = asm_alloc(sizeof(*newconst)); newconst = d3dcompiler_alloc(sizeof(*newconst));
if(!newconst) { if(!newconst) {
ERR("Failed to allocate a new constant\n"); ERR("Failed to allocate a new constant\n");
return FALSE; return FALSE;
@ -228,7 +228,7 @@ BOOL record_declaration(struct bwriter_shader *shader, DWORD usage,
} }
if(*num == 0) { if(*num == 0) {
*decl = asm_alloc(sizeof(**decl)); *decl = d3dcompiler_alloc(sizeof(**decl));
if(!*decl) { if(!*decl) {
ERR("Error allocating declarations array\n"); ERR("Error allocating declarations array\n");
return FALSE; return FALSE;
@ -242,7 +242,7 @@ BOOL record_declaration(struct bwriter_shader *shader, DWORD usage,
} }
} }
newdecl = asm_realloc(*decl, newdecl = d3dcompiler_realloc(*decl,
sizeof(**decl) * ((*num) + 1)); sizeof(**decl) * ((*num) + 1));
if(!newdecl) { if(!newdecl) {
ERR("Error reallocating declarations array\n"); ERR("Error reallocating declarations array\n");
@ -267,7 +267,7 @@ BOOL record_sampler(struct bwriter_shader *shader, DWORD samptype, DWORD mod, DW
if(!shader) return FALSE; if(!shader) return FALSE;
if(shader->num_samplers == 0) { if(shader->num_samplers == 0) {
shader->samplers = asm_alloc(sizeof(*shader->samplers)); shader->samplers = d3dcompiler_alloc(sizeof(*shader->samplers));
if(!shader->samplers) { if(!shader->samplers) {
ERR("Error allocating samplers array\n"); ERR("Error allocating samplers array\n");
return FALSE; return FALSE;
@ -284,7 +284,7 @@ BOOL record_sampler(struct bwriter_shader *shader, DWORD samptype, DWORD mod, DW
} }
} }
newarray = asm_realloc(shader->samplers, newarray = d3dcompiler_realloc(shader->samplers,
sizeof(*shader->samplers) * (shader->num_samplers + 1)); sizeof(*shader->samplers) * (shader->num_samplers + 1));
if(!newarray) { if(!newarray) {
ERR("Error reallocating samplers array\n"); ERR("Error reallocating samplers array\n");
@ -310,13 +310,13 @@ BOOL record_sampler(struct bwriter_shader *shader, DWORD samptype, DWORD mod, DW
static struct bytecode_buffer *allocate_buffer(void) { static struct bytecode_buffer *allocate_buffer(void) {
struct bytecode_buffer *ret; struct bytecode_buffer *ret;
ret = asm_alloc(sizeof(*ret)); ret = d3dcompiler_alloc(sizeof(*ret));
if(!ret) return NULL; if(!ret) return NULL;
ret->alloc_size = BYTECODEBUFFER_INITIAL_SIZE; ret->alloc_size = BYTECODEBUFFER_INITIAL_SIZE;
ret->data = asm_alloc(sizeof(DWORD) * ret->alloc_size); ret->data = d3dcompiler_alloc(sizeof(DWORD) * ret->alloc_size);
if(!ret->data) { if(!ret->data) {
asm_free(ret); d3dcompiler_free(ret);
return NULL; return NULL;
} }
ret->state = S_OK; ret->state = S_OK;
@ -329,7 +329,7 @@ static void put_dword(struct bytecode_buffer *buffer, DWORD value) {
if(buffer->alloc_size == buffer->size) { if(buffer->alloc_size == buffer->size) {
DWORD *newarray; DWORD *newarray;
buffer->alloc_size *= 2; buffer->alloc_size *= 2;
newarray = asm_realloc(buffer->data, newarray = d3dcompiler_realloc(buffer->data,
sizeof(DWORD) * buffer->alloc_size); sizeof(DWORD) * buffer->alloc_size);
if(!newarray) { if(!newarray) {
ERR("Failed to grow the buffer data memory\n"); ERR("Failed to grow the buffer data memory\n");
@ -2405,7 +2405,7 @@ static void init_ps30_dx9_writer(struct bc_writer *writer) {
} }
static struct bc_writer *create_writer(DWORD version, DWORD dxversion) { static struct bc_writer *create_writer(DWORD version, DWORD dxversion) {
struct bc_writer *ret = asm_alloc(sizeof(*ret)); struct bc_writer *ret = d3dcompiler_alloc(sizeof(*ret));
if(!ret) { if(!ret) {
WARN("Failed to allocate a bytecode writer instance\n"); WARN("Failed to allocate a bytecode writer instance\n");
@ -2517,7 +2517,7 @@ static struct bc_writer *create_writer(DWORD version, DWORD dxversion) {
return ret; return ret;
fail: fail:
asm_free(ret); d3dcompiler_free(ret);
return NULL; return NULL;
} }
@ -2611,7 +2611,7 @@ DWORD SlWriteBytecode(const struct bwriter_shader *shader, int dxversion, DWORD
} }
/* Cut off unneeded memory from the result buffer */ /* Cut off unneeded memory from the result buffer */
*result = asm_realloc(buffer->data, *result = d3dcompiler_realloc(buffer->data,
sizeof(DWORD) * buffer->size); sizeof(DWORD) * buffer->size);
if(!*result) { if(!*result) {
*result = buffer->data; *result = buffer->data;
@ -2621,10 +2621,10 @@ DWORD SlWriteBytecode(const struct bwriter_shader *shader, int dxversion, DWORD
error: error:
if(buffer) { if(buffer) {
asm_free(buffer->data); d3dcompiler_free(buffer->data);
asm_free(buffer); d3dcompiler_free(buffer);
} }
asm_free(writer); d3dcompiler_free(writer);
return hr; return hr;
} }
@ -2634,30 +2634,30 @@ void SlDeleteShader(struct bwriter_shader *shader) {
TRACE("Deleting shader %p\n", shader); TRACE("Deleting shader %p\n", shader);
for(i = 0; i < shader->num_cf; i++) { for(i = 0; i < shader->num_cf; i++) {
asm_free(shader->constF[i]); d3dcompiler_free(shader->constF[i]);
} }
asm_free(shader->constF); d3dcompiler_free(shader->constF);
for(i = 0; i < shader->num_ci; i++) { for(i = 0; i < shader->num_ci; i++) {
asm_free(shader->constI[i]); d3dcompiler_free(shader->constI[i]);
} }
asm_free(shader->constI); d3dcompiler_free(shader->constI);
for(i = 0; i < shader->num_cb; i++) { for(i = 0; i < shader->num_cb; i++) {
asm_free(shader->constB[i]); d3dcompiler_free(shader->constB[i]);
} }
asm_free(shader->constB); d3dcompiler_free(shader->constB);
asm_free(shader->inputs); d3dcompiler_free(shader->inputs);
asm_free(shader->outputs); d3dcompiler_free(shader->outputs);
asm_free(shader->samplers); d3dcompiler_free(shader->samplers);
for(i = 0; i < shader->num_instrs; i++) { for(i = 0; i < shader->num_instrs; i++) {
for(j = 0; j < shader->instr[i]->num_srcs; j++) { for(j = 0; j < shader->instr[i]->num_srcs; j++) {
asm_free(shader->instr[i]->src[j].rel_reg); d3dcompiler_free(shader->instr[i]->src[j].rel_reg);
} }
asm_free(shader->instr[i]->src); d3dcompiler_free(shader->instr[i]->src);
asm_free(shader->instr[i]); d3dcompiler_free(shader->instr[i]);
} }
asm_free(shader->instr); d3dcompiler_free(shader->instr);
asm_free(shader); d3dcompiler_free(shader);
} }

View File

@ -2,6 +2,7 @@
* Copyright 2008 Stefan Dösinger * Copyright 2008 Stefan Dösinger
* Copyright 2009 Matteo Bruni * Copyright 2009 Matteo Bruni
* Copyright 2010 Rico Schüller * Copyright 2010 Rico Schüller
* Copyright 2012 Matteo Bruni for CodeWeavers
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -138,15 +139,18 @@ struct bwriter_shader {
unsigned int num_instrs, instr_alloc_size; unsigned int num_instrs, instr_alloc_size;
}; };
static inline LPVOID asm_alloc(SIZE_T size) { static inline void *d3dcompiler_alloc(SIZE_T size)
{
return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size); return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
} }
static inline LPVOID asm_realloc(LPVOID ptr, SIZE_T size) { static inline void *d3dcompiler_realloc(void *ptr, SIZE_T size)
{
return HeapReAlloc(GetProcessHeap(), 0, ptr, size); return HeapReAlloc(GetProcessHeap(), 0, ptr, size);
} }
static inline BOOL asm_free(LPVOID ptr) { static inline BOOL d3dcompiler_free(void *ptr)
{
return HeapFree(GetProcessHeap(), 0, ptr); return HeapFree(GetProcessHeap(), 0, ptr);
} }

View File

@ -725,7 +725,7 @@ void compilation_message(struct compilation_messages *msg, const char *fmt, va_l
if (msg->capacity == 0) if (msg->capacity == 0)
{ {
msg->string = asm_alloc(MESSAGEBUFFER_INITIAL_SIZE); msg->string = d3dcompiler_alloc(MESSAGEBUFFER_INITIAL_SIZE);
if (msg->string == NULL) if (msg->string == NULL)
{ {
ERR("Error allocating memory for parser messages\n"); ERR("Error allocating memory for parser messages\n");
@ -742,7 +742,7 @@ void compilation_message(struct compilation_messages *msg, const char *fmt, va_l
if (rc < 0 || rc >= msg->capacity - msg->size) if (rc < 0 || rc >= msg->capacity - msg->size)
{ {
size = msg->capacity * 2; size = msg->capacity * 2;
buffer = asm_realloc(msg->string, size); buffer = d3dcompiler_realloc(msg->string, size);
if (buffer == NULL) if (buffer == NULL)
{ {
ERR("Error reallocating memory for parser messages\n"); ERR("Error reallocating memory for parser messages\n");