Commit 796f2822 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

vbscript: Use CRT allocation functions.

parent ffac93db
...@@ -155,7 +155,7 @@ static unsigned push_instr(compile_ctx_t *ctx, vbsop_t op) ...@@ -155,7 +155,7 @@ static unsigned push_instr(compile_ctx_t *ctx, vbsop_t op)
if(ctx->instr_size == ctx->instr_cnt) { if(ctx->instr_size == ctx->instr_cnt) {
instr_t *new_instr; instr_t *new_instr;
new_instr = heap_realloc(ctx->code->instrs, ctx->instr_size*2*sizeof(instr_t)); new_instr = realloc(ctx->code->instrs, ctx->instr_size*2*sizeof(instr_t));
if(!new_instr) if(!new_instr)
return 0; return 0;
...@@ -260,14 +260,14 @@ static HRESULT push_instr_date(compile_ctx_t *ctx, vbsop_t op, DATE arg) ...@@ -260,14 +260,14 @@ static HRESULT push_instr_date(compile_ctx_t *ctx, vbsop_t op, DATE arg)
static BSTR alloc_bstr_arg(compile_ctx_t *ctx, const WCHAR *str) static BSTR alloc_bstr_arg(compile_ctx_t *ctx, const WCHAR *str)
{ {
if(!ctx->code->bstr_pool_size) { if(!ctx->code->bstr_pool_size) {
ctx->code->bstr_pool = heap_alloc(8 * sizeof(BSTR)); ctx->code->bstr_pool = malloc(8 * sizeof(BSTR));
if(!ctx->code->bstr_pool) if(!ctx->code->bstr_pool)
return NULL; return NULL;
ctx->code->bstr_pool_size = 8; ctx->code->bstr_pool_size = 8;
}else if(ctx->code->bstr_pool_size == ctx->code->bstr_cnt) { }else if(ctx->code->bstr_pool_size == ctx->code->bstr_cnt) {
BSTR *new_pool; BSTR *new_pool;
new_pool = heap_realloc(ctx->code->bstr_pool, ctx->code->bstr_pool_size*2*sizeof(BSTR)); new_pool = realloc(ctx->code->bstr_pool, ctx->code->bstr_pool_size*2*sizeof(BSTR));
if(!new_pool) if(!new_pool)
return NULL; return NULL;
...@@ -340,14 +340,14 @@ static HRESULT push_instr_uint_bstr(compile_ctx_t *ctx, vbsop_t op, unsigned arg ...@@ -340,14 +340,14 @@ static HRESULT push_instr_uint_bstr(compile_ctx_t *ctx, vbsop_t op, unsigned arg
static unsigned alloc_label(compile_ctx_t *ctx) static unsigned alloc_label(compile_ctx_t *ctx)
{ {
if(!ctx->labels_size) { if(!ctx->labels_size) {
ctx->labels = heap_alloc(8 * sizeof(*ctx->labels)); ctx->labels = malloc(8 * sizeof(*ctx->labels));
if(!ctx->labels) if(!ctx->labels)
return 0; return 0;
ctx->labels_size = 8; ctx->labels_size = 8;
}else if(ctx->labels_size == ctx->labels_cnt) { }else if(ctx->labels_size == ctx->labels_cnt) {
unsigned *new_labels; unsigned *new_labels;
new_labels = heap_realloc(ctx->labels, 2*ctx->labels_size*sizeof(*ctx->labels)); new_labels = realloc(ctx->labels, 2*ctx->labels_size*sizeof(*ctx->labels));
if(!new_labels) if(!new_labels)
return 0; return 0;
...@@ -963,7 +963,7 @@ static HRESULT compile_select_statement(compile_ctx_t *ctx, select_statement_t * ...@@ -963,7 +963,7 @@ static HRESULT compile_select_statement(compile_ctx_t *ctx, select_statement_t *
case_cnt++; case_cnt++;
if(case_cnt) { if(case_cnt) {
case_labels = heap_alloc(case_cnt*sizeof(*case_labels)); case_labels = malloc(case_cnt*sizeof(*case_labels));
if(!case_labels) if(!case_labels)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
...@@ -995,19 +995,19 @@ static HRESULT compile_select_statement(compile_ctx_t *ctx, select_statement_t * ...@@ -995,19 +995,19 @@ static HRESULT compile_select_statement(compile_ctx_t *ctx, select_statement_t *
} }
if(FAILED(hres)) { if(FAILED(hres)) {
heap_free(case_labels); free(case_labels);
return hres; return hres;
} }
hres = push_instr_uint(ctx, OP_pop, 1); hres = push_instr_uint(ctx, OP_pop, 1);
if(FAILED(hres)) { if(FAILED(hres)) {
heap_free(case_labels); free(case_labels);
return hres; return hres;
} }
hres = push_instr_addr(ctx, OP_jmp, case_iter ? case_labels[i] : end_label); hres = push_instr_addr(ctx, OP_jmp, case_iter ? case_labels[i] : end_label);
if(FAILED(hres)) { if(FAILED(hres)) {
heap_free(case_labels); free(case_labels);
return hres; return hres;
} }
...@@ -1025,7 +1025,7 @@ static HRESULT compile_select_statement(compile_ctx_t *ctx, select_statement_t * ...@@ -1025,7 +1025,7 @@ static HRESULT compile_select_statement(compile_ctx_t *ctx, select_statement_t *
break; break;
} }
heap_free(case_labels); free(case_labels);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
...@@ -1923,10 +1923,10 @@ void release_vbscode(vbscode_t *code) ...@@ -1923,10 +1923,10 @@ void release_vbscode(vbscode_t *code)
release_named_item(code->named_item); release_named_item(code->named_item);
heap_pool_free(&code->heap); heap_pool_free(&code->heap);
heap_free(code->bstr_pool); free(code->bstr_pool);
heap_free(code->source); free(code->source);
heap_free(code->instrs); free(code->instrs);
heap_free(code); free(code);
} }
static vbscode_t *alloc_vbscode(compile_ctx_t *ctx, const WCHAR *source, DWORD_PTR cookie, unsigned start_line) static vbscode_t *alloc_vbscode(compile_ctx_t *ctx, const WCHAR *source, DWORD_PTR cookie, unsigned start_line)
...@@ -1938,13 +1938,13 @@ static vbscode_t *alloc_vbscode(compile_ctx_t *ctx, const WCHAR *source, DWORD_P ...@@ -1938,13 +1938,13 @@ static vbscode_t *alloc_vbscode(compile_ctx_t *ctx, const WCHAR *source, DWORD_P
if(len > INT32_MAX) if(len > INT32_MAX)
return NULL; return NULL;
ret = heap_alloc_zero(sizeof(*ret)); ret = calloc(1, sizeof(*ret));
if(!ret) if(!ret)
return NULL; return NULL;
ret->source = heap_alloc((len + 1) * sizeof(WCHAR)); ret->source = malloc((len + 1) * sizeof(WCHAR));
if(!ret->source) { if(!ret->source) {
heap_free(ret); free(ret);
return NULL; return NULL;
} }
if(len) if(len)
...@@ -1954,7 +1954,7 @@ static vbscode_t *alloc_vbscode(compile_ctx_t *ctx, const WCHAR *source, DWORD_P ...@@ -1954,7 +1954,7 @@ static vbscode_t *alloc_vbscode(compile_ctx_t *ctx, const WCHAR *source, DWORD_P
ret->cookie = cookie; ret->cookie = cookie;
ret->start_line = start_line; ret->start_line = start_line;
ret->instrs = heap_alloc(32*sizeof(instr_t)); ret->instrs = malloc(32*sizeof(instr_t));
if(!ret->instrs) { if(!ret->instrs) {
release_vbscode(ret); release_vbscode(ret);
return NULL; return NULL;
...@@ -1975,7 +1975,7 @@ static vbscode_t *alloc_vbscode(compile_ctx_t *ctx, const WCHAR *source, DWORD_P ...@@ -1975,7 +1975,7 @@ static vbscode_t *alloc_vbscode(compile_ctx_t *ctx, const WCHAR *source, DWORD_P
static void release_compiler(compile_ctx_t *ctx) static void release_compiler(compile_ctx_t *ctx)
{ {
parser_release(&ctx->parser); parser_release(&ctx->parser);
heap_free(ctx->labels); free(ctx->labels);
if(ctx->code) if(ctx->code)
release_vbscode(ctx->code); release_vbscode(ctx->code);
} }
......
...@@ -98,7 +98,7 @@ static ULONG WINAPI Builtin_Release(IDispatch *iface) ...@@ -98,7 +98,7 @@ static ULONG WINAPI Builtin_Release(IDispatch *iface)
if(!ref) { if(!ref) {
assert(!This->ctx); assert(!This->ctx);
heap_free(This); free(This);
} }
return ref; return ref;
...@@ -249,7 +249,7 @@ static HRESULT WINAPI Builtin_Invoke(IDispatch *iface, DISPID id, REFIID riid, L ...@@ -249,7 +249,7 @@ static HRESULT WINAPI Builtin_Invoke(IDispatch *iface, DISPID id, REFIID riid, L
if(argn <= ARRAY_SIZE(args_buf)) { if(argn <= ARRAY_SIZE(args_buf)) {
args = args_buf; args = args_buf;
}else { }else {
args = heap_alloc(argn * sizeof(*args)); args = malloc(argn * sizeof(*args));
if(!args) if(!args)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
...@@ -263,7 +263,7 @@ static HRESULT WINAPI Builtin_Invoke(IDispatch *iface, DISPID id, REFIID riid, L ...@@ -263,7 +263,7 @@ static HRESULT WINAPI Builtin_Invoke(IDispatch *iface, DISPID id, REFIID riid, L
hres = prop->proc(This, args, dp->cArgs, res); hres = prop->proc(This, args, dp->cArgs, res);
if(args != args_buf) if(args != args_buf)
heap_free(args); free(args);
return hres; return hres;
} }
...@@ -281,7 +281,7 @@ static HRESULT create_builtin_dispatch(script_ctx_t *ctx, const builtin_prop_t * ...@@ -281,7 +281,7 @@ static HRESULT create_builtin_dispatch(script_ctx_t *ctx, const builtin_prop_t *
{ {
BuiltinDisp *disp; BuiltinDisp *disp;
if(!(disp = heap_alloc(sizeof(*disp)))) if(!(disp = malloc(sizeof(*disp))))
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
disp->IDispatch_iface.lpVtbl = &BuiltinDispVtbl; disp->IDispatch_iface.lpVtbl = &BuiltinDispVtbl;
...@@ -611,7 +611,7 @@ static HRESULT show_msgbox(script_ctx_t *ctx, BSTR prompt, unsigned type, BSTR o ...@@ -611,7 +611,7 @@ static HRESULT show_msgbox(script_ctx_t *ctx, BSTR prompt, unsigned type, BSTR o
if(orig_title && *orig_title) { if(orig_title && *orig_title) {
WCHAR *ptr; WCHAR *ptr;
title = title_buf = heap_alloc(sizeof(L"VBScript") + (lstrlenW(orig_title)+2)*sizeof(WCHAR)); title = title_buf = malloc(sizeof(L"VBScript") + (lstrlenW(orig_title)+2)*sizeof(WCHAR));
if(!title) if(!title)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
...@@ -637,7 +637,7 @@ static HRESULT show_msgbox(script_ctx_t *ctx, BSTR prompt, unsigned type, BSTR o ...@@ -637,7 +637,7 @@ static HRESULT show_msgbox(script_ctx_t *ctx, BSTR prompt, unsigned type, BSTR o
} }
} }
heap_free(title_buf); free(title_buf);
IActiveScriptSiteWindow_Release(acts_window); IActiveScriptSiteWindow_Release(acts_window);
if(FAILED(hres)) { if(FAILED(hres)) {
FIXME("failed: %08lx\n", hres); FIXME("failed: %08lx\n", hres);
...@@ -2630,7 +2630,7 @@ static HRESULT Global_Split(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, ...@@ -2630,7 +2630,7 @@ static HRESULT Global_Split(BuiltinDisp *This, VARIANT *args, unsigned args_cnt,
len = SysStringLen(string); len = SysStringLen(string);
count = 0; count = 0;
indices = heap_alloc( indices_max * sizeof(int)); indices = malloc( indices_max * sizeof(int));
if(!indices) { if(!indices) {
hres = E_OUTOFMEMORY; hres = E_OUTOFMEMORY;
goto error; goto error;
...@@ -2651,7 +2651,7 @@ static HRESULT Global_Split(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, ...@@ -2651,7 +2651,7 @@ static HRESULT Global_Split(BuiltinDisp *This, VARIANT *args, unsigned args_cnt,
if (count == indices_max) { if (count == indices_max) {
indices_max *= 2; indices_max *= 2;
indices = heap_realloc( indices, indices_max * sizeof(int)); indices = realloc( indices, indices_max * sizeof(int));
if(!indices) { if(!indices) {
hres = E_OUTOFMEMORY; hres = E_OUTOFMEMORY;
goto error; goto error;
...@@ -2703,7 +2703,7 @@ error: ...@@ -2703,7 +2703,7 @@ error:
SafeArrayDestroy(sa); SafeArrayDestroy(sa);
} }
heap_free(indices); free(indices);
if(V_VT(args) != VT_BSTR) if(V_VT(args) != VT_BSTR)
SysFreeString(string); SysFreeString(string);
if(args_cnt > 1 && V_VT(args+1) != VT_BSTR) if(args_cnt > 1 && V_VT(args+1) != VT_BSTR)
......
...@@ -267,9 +267,9 @@ static HRESULT add_dynamic_var(exec_ctx_t *ctx, const WCHAR *name, ...@@ -267,9 +267,9 @@ static HRESULT add_dynamic_var(exec_ctx_t *ctx, const WCHAR *name,
if(cnt > script_obj->global_vars_size) { if(cnt > script_obj->global_vars_size) {
dynamic_var_t **new_vars; dynamic_var_t **new_vars;
if(script_obj->global_vars) if(script_obj->global_vars)
new_vars = heap_realloc(script_obj->global_vars, cnt * 2 * sizeof(*new_vars)); new_vars = realloc(script_obj->global_vars, cnt * 2 * sizeof(*new_vars));
else else
new_vars = heap_alloc(cnt * 2 * sizeof(*new_vars)); new_vars = malloc(cnt * 2 * sizeof(*new_vars));
if(!new_vars) if(!new_vars)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
script_obj->global_vars = new_vars; script_obj->global_vars = new_vars;
...@@ -318,7 +318,7 @@ static HRESULT stack_push(exec_ctx_t *ctx, VARIANT *v) ...@@ -318,7 +318,7 @@ static HRESULT stack_push(exec_ctx_t *ctx, VARIANT *v)
if(ctx->stack_size == ctx->top) { if(ctx->stack_size == ctx->top) {
VARIANT *new_stack; VARIANT *new_stack;
new_stack = heap_realloc(ctx->stack, ctx->stack_size*2*sizeof(*ctx->stack)); new_stack = realloc(ctx->stack, ctx->stack_size*2*sizeof(*ctx->stack));
if(!new_stack) { if(!new_stack) {
VariantClear(v); VariantClear(v);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
...@@ -556,7 +556,7 @@ static HRESULT array_access(exec_ctx_t *ctx, SAFEARRAY *array, DISPPARAMS *dp, V ...@@ -556,7 +556,7 @@ static HRESULT array_access(exec_ctx_t *ctx, SAFEARRAY *array, DISPPARAMS *dp, V
return E_FAIL; return E_FAIL;
} }
indices = heap_alloc(sizeof(*indices) * argc); indices = malloc(sizeof(*indices) * argc);
if(!indices) { if(!indices) {
SafeArrayUnlock(array); SafeArrayUnlock(array);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
...@@ -565,7 +565,7 @@ static HRESULT array_access(exec_ctx_t *ctx, SAFEARRAY *array, DISPPARAMS *dp, V ...@@ -565,7 +565,7 @@ static HRESULT array_access(exec_ctx_t *ctx, SAFEARRAY *array, DISPPARAMS *dp, V
for(i=0; i<argc; i++) { for(i=0; i<argc; i++) {
hres = to_int(get_arg(dp, i), (int *)(indices+i)); hres = to_int(get_arg(dp, i), (int *)(indices+i));
if(FAILED(hres)) { if(FAILED(hres)) {
heap_free(indices); free(indices);
SafeArrayUnlock(array); SafeArrayUnlock(array);
return hres; return hres;
} }
...@@ -573,7 +573,7 @@ static HRESULT array_access(exec_ctx_t *ctx, SAFEARRAY *array, DISPPARAMS *dp, V ...@@ -573,7 +573,7 @@ static HRESULT array_access(exec_ctx_t *ctx, SAFEARRAY *array, DISPPARAMS *dp, V
hres = SafeArrayPtrOfIndex(array, indices, (void**)ret); hres = SafeArrayPtrOfIndex(array, indices, (void**)ret);
SafeArrayUnlock(array); SafeArrayUnlock(array);
heap_free(indices); free(indices);
return hres; return hres;
} }
...@@ -1216,7 +1216,7 @@ static HRESULT interp_dim(exec_ctx_t *ctx) ...@@ -1216,7 +1216,7 @@ static HRESULT interp_dim(exec_ctx_t *ctx)
ref_t ref; ref_t ref;
if(!ctx->arrays) { if(!ctx->arrays) {
ctx->arrays = heap_alloc_zero(ctx->func->array_cnt * sizeof(SAFEARRAY*)); ctx->arrays = calloc(ctx->func->array_cnt, sizeof(SAFEARRAY*));
if(!ctx->arrays) if(!ctx->arrays)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
...@@ -1260,13 +1260,13 @@ static HRESULT array_bounds_from_stack(exec_ctx_t *ctx, unsigned dim_cnt, SAFEAR ...@@ -1260,13 +1260,13 @@ static HRESULT array_bounds_from_stack(exec_ctx_t *ctx, unsigned dim_cnt, SAFEAR
int dim; int dim;
HRESULT hres; HRESULT hres;
if(!(bounds = heap_alloc(dim_cnt * sizeof(*bounds)))) if(!(bounds = malloc(dim_cnt * sizeof(*bounds))))
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
for(i = 0; i < dim_cnt; i++) { for(i = 0; i < dim_cnt; i++) {
hres = to_int(stack_top(ctx, dim_cnt - i - 1), &dim); hres = to_int(stack_top(ctx, dim_cnt - i - 1), &dim);
if(FAILED(hres)) { if(FAILED(hres)) {
heap_free(bounds); free(bounds);
return hres; return hres;
} }
...@@ -1306,7 +1306,7 @@ static HRESULT interp_redim(exec_ctx_t *ctx) ...@@ -1306,7 +1306,7 @@ static HRESULT interp_redim(exec_ctx_t *ctx)
return hres; return hres;
array = SafeArrayCreate(VT_VARIANT, dim_cnt, bounds); array = SafeArrayCreate(VT_VARIANT, dim_cnt, bounds);
heap_free(bounds); free(bounds);
if(!array) if(!array)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
...@@ -2398,13 +2398,13 @@ static void release_exec(exec_ctx_t *ctx) ...@@ -2398,13 +2398,13 @@ static void release_exec(exec_ctx_t *ctx)
if(ctx->arrays[i]) if(ctx->arrays[i])
SafeArrayDestroy(ctx->arrays[i]); SafeArrayDestroy(ctx->arrays[i]);
} }
heap_free(ctx->arrays); free(ctx->arrays);
} }
heap_pool_free(&ctx->heap); heap_pool_free(&ctx->heap);
heap_free(ctx->args); free(ctx->args);
heap_free(ctx->vars); free(ctx->vars);
heap_free(ctx->stack); free(ctx->stack);
} }
HRESULT exec_script(script_ctx_t *ctx, BOOL extern_caller, function_t *func, vbdisp_t *vbthis, DISPPARAMS *dp, VARIANT *res) HRESULT exec_script(script_ctx_t *ctx, BOOL extern_caller, function_t *func, vbdisp_t *vbthis, DISPPARAMS *dp, VARIANT *res)
...@@ -2427,7 +2427,7 @@ HRESULT exec_script(script_ctx_t *ctx, BOOL extern_caller, function_t *func, vbd ...@@ -2427,7 +2427,7 @@ HRESULT exec_script(script_ctx_t *ctx, BOOL extern_caller, function_t *func, vbd
VARIANT *v; VARIANT *v;
unsigned i; unsigned i;
exec.args = heap_alloc_zero(func->arg_cnt * sizeof(VARIANT)); exec.args = calloc(func->arg_cnt, sizeof(VARIANT));
if(!exec.args) { if(!exec.args) {
release_exec(&exec); release_exec(&exec);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
...@@ -2454,7 +2454,7 @@ HRESULT exec_script(script_ctx_t *ctx, BOOL extern_caller, function_t *func, vbd ...@@ -2454,7 +2454,7 @@ HRESULT exec_script(script_ctx_t *ctx, BOOL extern_caller, function_t *func, vbd
} }
if(func->var_cnt) { if(func->var_cnt) {
exec.vars = heap_alloc_zero(func->var_cnt * sizeof(VARIANT)); exec.vars = calloc(func->var_cnt, sizeof(VARIANT));
if(!exec.vars) { if(!exec.vars) {
release_exec(&exec); release_exec(&exec);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
...@@ -2465,7 +2465,7 @@ HRESULT exec_script(script_ctx_t *ctx, BOOL extern_caller, function_t *func, vbd ...@@ -2465,7 +2465,7 @@ HRESULT exec_script(script_ctx_t *ctx, BOOL extern_caller, function_t *func, vbd
exec.stack_size = 16; exec.stack_size = 16;
exec.top = 0; exec.top = 0;
exec.stack = heap_alloc(exec.stack_size * sizeof(VARIANT)); exec.stack = malloc(exec.stack_size * sizeof(VARIANT));
if(!exec.stack) { if(!exec.stack) {
release_exec(&exec); release_exec(&exec);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
......
...@@ -229,14 +229,14 @@ static int parse_date_literal(parser_ctx_t *ctx, DATE *ret) ...@@ -229,14 +229,14 @@ static int parse_date_literal(parser_ctx_t *ctx, DATE *ret)
len += ctx->ptr-ptr; len += ctx->ptr-ptr;
rptr = heap_alloc((len+1)*sizeof(WCHAR)); rptr = malloc((len+1)*sizeof(WCHAR));
if(!rptr) if(!rptr)
return 0; return 0;
memcpy( rptr, ptr, len * sizeof(WCHAR)); memcpy( rptr, ptr, len * sizeof(WCHAR));
rptr[len] = 0; rptr[len] = 0;
res = VarDateFromStr(rptr, ctx->lcid, 0, ret); res = VarDateFromStr(rptr, ctx->lcid, 0, ret);
heap_free(rptr); free(rptr);
if (FAILED(res)) { if (FAILED(res)) {
FIXME("Invalid date literal\n"); FIXME("Invalid date literal\n");
return 0; return 0;
......
...@@ -482,7 +482,7 @@ EmitREBytecode(CompilerState *state, regexp_t *re, size_t treeDepth, ...@@ -482,7 +482,7 @@ EmitREBytecode(CompilerState *state, regexp_t *re, size_t treeDepth,
if (treeDepth == 0) { if (treeDepth == 0) {
emitStateStack = NULL; emitStateStack = NULL;
} else { } else {
emitStateStack = heap_alloc(sizeof(EmitStateStackEntry) * treeDepth); emitStateStack = malloc(sizeof(EmitStateStackEntry) * treeDepth);
if (!emitStateStack) if (!emitStateStack)
return NULL; return NULL;
} }
...@@ -788,7 +788,7 @@ EmitREBytecode(CompilerState *state, regexp_t *re, size_t treeDepth, ...@@ -788,7 +788,7 @@ EmitREBytecode(CompilerState *state, regexp_t *re, size_t treeDepth,
} }
cleanup: cleanup:
heap_free(emitStateStack); free(emitStateStack);
return pc; return pc;
jump_too_big: jump_too_big:
...@@ -1667,11 +1667,11 @@ ParseRegExp(CompilerState *state) ...@@ -1667,11 +1667,11 @@ ParseRegExp(CompilerState *state)
return (state->result != NULL); return (state->result != NULL);
} }
operatorStack = heap_alloc(sizeof(REOpData) * operatorStackSize); operatorStack = malloc(sizeof(REOpData) * operatorStackSize);
if (!operatorStack) if (!operatorStack)
return FALSE; return FALSE;
operandStack = heap_alloc(sizeof(RENode *) * operandStackSize); operandStack = malloc(sizeof(RENode *) * operandStackSize);
if (!operandStack) if (!operandStack)
goto out; goto out;
...@@ -1762,7 +1762,7 @@ pushOperand: ...@@ -1762,7 +1762,7 @@ pushOperand:
if (operandSP == operandStackSize) { if (operandSP == operandStackSize) {
RENode **tmp; RENode **tmp;
operandStackSize += operandStackSize; operandStackSize += operandStackSize;
tmp = heap_realloc(operandStack, sizeof(RENode *) * operandStackSize); tmp = realloc(operandStack, sizeof(RENode *) * operandStackSize);
if (!tmp) if (!tmp)
goto out; goto out;
operandStack = tmp; operandStack = tmp;
...@@ -1895,7 +1895,7 @@ pushOperator: ...@@ -1895,7 +1895,7 @@ pushOperator:
if (operatorSP == operatorStackSize) { if (operatorSP == operatorStackSize) {
REOpData *tmp; REOpData *tmp;
operatorStackSize += operatorStackSize; operatorStackSize += operatorStackSize;
tmp = heap_realloc(operatorStack, sizeof(REOpData) * operatorStackSize); tmp = realloc(operatorStack, sizeof(REOpData) * operatorStackSize);
if (!tmp) if (!tmp)
goto out; goto out;
operatorStack = tmp; operatorStack = tmp;
...@@ -1907,8 +1907,8 @@ pushOperator: ...@@ -1907,8 +1907,8 @@ pushOperator:
} }
} }
out: out:
heap_free(operatorStack); free(operatorStack);
heap_free(operandStack); free(operandStack);
return result; return result;
} }
...@@ -2111,7 +2111,7 @@ ProcessCharSet(REGlobalData *gData, RECharSet *charSet) ...@@ -2111,7 +2111,7 @@ ProcessCharSet(REGlobalData *gData, RECharSet *charSet)
assert(src[-1] == '[' && end[0] == ']'); assert(src[-1] == '[' && end[0] == ']');
byteLength = (charSet->length >> 3) + 1; byteLength = (charSet->length >> 3) + 1;
charSet->u.bits = heap_alloc(byteLength); charSet->u.bits = malloc(byteLength);
if (!charSet->u.bits) { if (!charSet->u.bits) {
JS_ReportOutOfMemory(gData->cx); JS_ReportOutOfMemory(gData->cx);
gData->ok = FALSE; gData->ok = FALSE;
...@@ -3184,12 +3184,12 @@ void regexp_destroy(regexp_t *re) ...@@ -3184,12 +3184,12 @@ void regexp_destroy(regexp_t *re)
UINT i; UINT i;
for (i = 0; i < re->classCount; i++) { for (i = 0; i < re->classCount; i++) {
if (re->classList[i].converted) if (re->classList[i].converted)
heap_free(re->classList[i].u.bits); free(re->classList[i].u.bits);
re->classList[i].u.bits = NULL; re->classList[i].u.bits = NULL;
} }
heap_free(re->classList); free(re->classList);
} }
heap_free(re); free(re);
} }
regexp_t* regexp_new(void *cx, heap_pool_t *pool, const WCHAR *str, regexp_t* regexp_new(void *cx, heap_pool_t *pool, const WCHAR *str,
...@@ -3238,14 +3238,14 @@ regexp_t* regexp_new(void *cx, heap_pool_t *pool, const WCHAR *str, ...@@ -3238,14 +3238,14 @@ regexp_t* regexp_new(void *cx, heap_pool_t *pool, const WCHAR *str,
goto out; goto out;
} }
resize = offsetof(regexp_t, program) + state.progLength + 1; resize = offsetof(regexp_t, program) + state.progLength + 1;
re = heap_alloc(resize); re = malloc(resize);
if (!re) if (!re)
goto out; goto out;
assert(state.classBitmapsMem <= CLASS_BITMAPS_MEM_LIMIT); assert(state.classBitmapsMem <= CLASS_BITMAPS_MEM_LIMIT);
re->classCount = state.classCount; re->classCount = state.classCount;
if (re->classCount) { if (re->classCount) {
re->classList = heap_alloc(re->classCount * sizeof(RECharSet)); re->classList = malloc(re->classCount * sizeof(RECharSet));
if (!re->classList) { if (!re->classList) {
regexp_destroy(re); regexp_destroy(re);
re = NULL; re = NULL;
...@@ -3272,7 +3272,7 @@ regexp_t* regexp_new(void *cx, heap_pool_t *pool, const WCHAR *str, ...@@ -3272,7 +3272,7 @@ regexp_t* regexp_new(void *cx, heap_pool_t *pool, const WCHAR *str,
regexp_t *tmp; regexp_t *tmp;
assert((size_t)(endPC - re->program) < state.progLength + 1); assert((size_t)(endPC - re->program) < state.progLength + 1);
resize = offsetof(regexp_t, program) + (endPC - re->program); resize = offsetof(regexp_t, program) + (endPC - re->program);
tmp = heap_realloc(re, resize); tmp = realloc(re, resize);
if (tmp) if (tmp)
re = tmp; re = tmp;
} }
......
...@@ -73,7 +73,7 @@ static inline match_state_t* alloc_match_state(regexp_t *regexp, ...@@ -73,7 +73,7 @@ static inline match_state_t* alloc_match_state(regexp_t *regexp,
size_t size = offsetof(match_state_t, parens) + regexp->parenCount*sizeof(RECapture); size_t size = offsetof(match_state_t, parens) + regexp->parenCount*sizeof(RECapture);
match_state_t *ret; match_state_t *ret;
ret = pool ? heap_pool_alloc(pool, size) : heap_alloc(size); ret = pool ? heap_pool_alloc(pool, size) : malloc(size);
if(!ret) if(!ret)
return NULL; return NULL;
......
...@@ -77,7 +77,7 @@ static ULONG WINAPI safearray_iter_IEnumVARIANT_Release(IEnumVARIANT *iface) ...@@ -77,7 +77,7 @@ static ULONG WINAPI safearray_iter_IEnumVARIANT_Release(IEnumVARIANT *iface)
if(!ref) { if(!ref) {
if(This->sa) if(This->sa)
SafeArrayUnlock(This->sa); SafeArrayUnlock(This->sa);
heap_free(This); free(This);
} }
return ref; return ref;
...@@ -170,14 +170,14 @@ HRESULT create_safearray_iter(SAFEARRAY *sa, IEnumVARIANT **ev) ...@@ -170,14 +170,14 @@ HRESULT create_safearray_iter(SAFEARRAY *sa, IEnumVARIANT **ev)
return E_NOTIMPL; return E_NOTIMPL;
} }
iter = heap_alloc(sizeof(*iter)); iter = malloc(sizeof(*iter));
if(!iter) if(!iter)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
if(sa) { if(sa) {
hres = SafeArrayLock(sa); hres = SafeArrayLock(sa);
if(FAILED(hres)) { if(FAILED(hres)) {
heap_free(iter); free(iter);
return hres; return hres;
} }
} }
......
...@@ -203,7 +203,7 @@ static HRESULT invoke_vbdisp(vbdisp_t *This, DISPID id, DWORD flags, BOOL extern ...@@ -203,7 +203,7 @@ static HRESULT invoke_vbdisp(vbdisp_t *This, DISPID id, DWORD flags, BOOL extern
dp.cArgs = arg_cnt(params) + 1; dp.cArgs = arg_cnt(params) + 1;
if(dp.cArgs > ARRAY_SIZE(buf)) { if(dp.cArgs > ARRAY_SIZE(buf)) {
dp.rgvarg = heap_alloc(dp.cArgs*sizeof(VARIANT)); dp.rgvarg = malloc(dp.cArgs*sizeof(VARIANT));
if(!dp.rgvarg) if(!dp.rgvarg)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
}else { }else {
...@@ -213,7 +213,7 @@ static HRESULT invoke_vbdisp(vbdisp_t *This, DISPID id, DWORD flags, BOOL extern ...@@ -213,7 +213,7 @@ static HRESULT invoke_vbdisp(vbdisp_t *This, DISPID id, DWORD flags, BOOL extern
hres = get_propput_arg(This->desc->ctx, params, flags, dp.rgvarg, &needs_release); hres = get_propput_arg(This->desc->ctx, params, flags, dp.rgvarg, &needs_release);
if(FAILED(hres)) { if(FAILED(hres)) {
if(dp.rgvarg != buf) if(dp.rgvarg != buf)
heap_free(dp.rgvarg); free(dp.rgvarg);
return hres; return hres;
} }
...@@ -221,7 +221,7 @@ static HRESULT invoke_vbdisp(vbdisp_t *This, DISPID id, DWORD flags, BOOL extern ...@@ -221,7 +221,7 @@ static HRESULT invoke_vbdisp(vbdisp_t *This, DISPID id, DWORD flags, BOOL extern
if(!func) { if(!func) {
FIXME("no letter/setter\n"); FIXME("no letter/setter\n");
if(dp.rgvarg != buf) if(dp.rgvarg != buf)
heap_free(dp.rgvarg); free(dp.rgvarg);
return DISP_E_MEMBERNOTFOUND; return DISP_E_MEMBERNOTFOUND;
} }
...@@ -233,7 +233,7 @@ static HRESULT invoke_vbdisp(vbdisp_t *This, DISPID id, DWORD flags, BOOL extern ...@@ -233,7 +233,7 @@ static HRESULT invoke_vbdisp(vbdisp_t *This, DISPID id, DWORD flags, BOOL extern
if(needs_release) if(needs_release)
VariantClear(dp.rgvarg); VariantClear(dp.rgvarg);
if(dp.rgvarg != buf) if(dp.rgvarg != buf)
heap_free(dp.rgvarg); free(dp.rgvarg);
return hres; return hres;
} }
default: default:
...@@ -332,8 +332,8 @@ static ULONG WINAPI DispatchEx_Release(IDispatchEx *iface) ...@@ -332,8 +332,8 @@ static ULONG WINAPI DispatchEx_Release(IDispatchEx *iface)
if(!ref && run_terminator(This)) { if(!ref && run_terminator(This)) {
clean_props(This); clean_props(This);
list_remove(&This->entry); list_remove(&This->entry);
heap_free(This->arrays); free(This->arrays);
heap_free(This); free(This);
} }
return ref; return ref;
...@@ -488,7 +488,7 @@ HRESULT create_vbdisp(const class_desc_t *desc, vbdisp_t **ret) ...@@ -488,7 +488,7 @@ HRESULT create_vbdisp(const class_desc_t *desc, vbdisp_t **ret)
vbdisp_t *vbdisp; vbdisp_t *vbdisp;
HRESULT hres = S_OK; HRESULT hres = S_OK;
vbdisp = heap_alloc_zero( FIELD_OFFSET( vbdisp_t, props[desc->prop_cnt] )); vbdisp = calloc( 1, FIELD_OFFSET( vbdisp_t, props[desc->prop_cnt] ));
if(!vbdisp) if(!vbdisp)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
...@@ -499,7 +499,7 @@ HRESULT create_vbdisp(const class_desc_t *desc, vbdisp_t **ret) ...@@ -499,7 +499,7 @@ HRESULT create_vbdisp(const class_desc_t *desc, vbdisp_t **ret)
list_add_tail(&desc->ctx->objects, &vbdisp->entry); list_add_tail(&desc->ctx->objects, &vbdisp->entry);
if(desc->array_cnt) { if(desc->array_cnt) {
vbdisp->arrays = heap_alloc_zero(desc->array_cnt * sizeof(*vbdisp->arrays)); vbdisp->arrays = calloc(desc->array_cnt, sizeof(*vbdisp->arrays));
if(vbdisp->arrays) { if(vbdisp->arrays) {
unsigned i, j; unsigned i, j;
...@@ -633,8 +633,8 @@ static ULONG WINAPI ScriptTypeInfo_Release(ITypeInfo *iface) ...@@ -633,8 +633,8 @@ static ULONG WINAPI ScriptTypeInfo_Release(ITypeInfo *iface)
release_vbscode(This->funcs[i].func->code_ctx); release_vbscode(This->funcs[i].func->code_ctx);
IDispatchEx_Release(&This->disp->IDispatchEx_iface); IDispatchEx_Release(&This->disp->IDispatchEx_iface);
heap_free(This->funcs); free(This->funcs);
heap_free(This); free(This);
} }
return ref; return ref;
} }
...@@ -648,7 +648,7 @@ static HRESULT WINAPI ScriptTypeInfo_GetTypeAttr(ITypeInfo *iface, TYPEATTR **pp ...@@ -648,7 +648,7 @@ static HRESULT WINAPI ScriptTypeInfo_GetTypeAttr(ITypeInfo *iface, TYPEATTR **pp
if (!ppTypeAttr) return E_INVALIDARG; if (!ppTypeAttr) return E_INVALIDARG;
attr = heap_alloc_zero(sizeof(*attr)); attr = calloc(1, sizeof(*attr));
if (!attr) return E_OUTOFMEMORY; if (!attr) return E_OUTOFMEMORY;
attr->guid = GUID_VBScriptTypeInfo; attr->guid = GUID_VBScriptTypeInfo;
...@@ -697,7 +697,7 @@ static HRESULT WINAPI ScriptTypeInfo_GetFuncDesc(ITypeInfo *iface, UINT index, F ...@@ -697,7 +697,7 @@ static HRESULT WINAPI ScriptTypeInfo_GetFuncDesc(ITypeInfo *iface, UINT index, F
func = This->funcs[index].func; func = This->funcs[index].func;
/* Store the parameter array after the FUNCDESC structure */ /* Store the parameter array after the FUNCDESC structure */
desc = heap_alloc_zero(sizeof(*desc) + sizeof(ELEMDESC) * func->arg_cnt); desc = calloc(1, sizeof(*desc) + sizeof(ELEMDESC) * func->arg_cnt);
if (!desc) return E_OUTOFMEMORY; if (!desc) return E_OUTOFMEMORY;
desc->memid = This->funcs[index].memid; desc->memid = This->funcs[index].memid;
...@@ -725,7 +725,7 @@ static HRESULT WINAPI ScriptTypeInfo_GetVarDesc(ITypeInfo *iface, UINT index, VA ...@@ -725,7 +725,7 @@ static HRESULT WINAPI ScriptTypeInfo_GetVarDesc(ITypeInfo *iface, UINT index, VA
if (!ppVarDesc) return E_INVALIDARG; if (!ppVarDesc) return E_INVALIDARG;
if (index >= This->num_vars) return TYPE_E_ELEMENTNOTFOUND; if (index >= This->num_vars) return TYPE_E_ELEMENTNOTFOUND;
desc = heap_alloc_zero(sizeof(*desc)); desc = calloc(1, sizeof(*desc));
if (!desc) return E_OUTOFMEMORY; if (!desc) return E_OUTOFMEMORY;
desc->memid = index + 1; desc->memid = index + 1;
...@@ -1061,7 +1061,7 @@ static void WINAPI ScriptTypeInfo_ReleaseTypeAttr(ITypeInfo *iface, TYPEATTR *pT ...@@ -1061,7 +1061,7 @@ static void WINAPI ScriptTypeInfo_ReleaseTypeAttr(ITypeInfo *iface, TYPEATTR *pT
TRACE("(%p)->(%p)\n", This, pTypeAttr); TRACE("(%p)->(%p)\n", This, pTypeAttr);
heap_free(pTypeAttr); free(pTypeAttr);
} }
static void WINAPI ScriptTypeInfo_ReleaseFuncDesc(ITypeInfo *iface, FUNCDESC *pFuncDesc) static void WINAPI ScriptTypeInfo_ReleaseFuncDesc(ITypeInfo *iface, FUNCDESC *pFuncDesc)
...@@ -1070,7 +1070,7 @@ static void WINAPI ScriptTypeInfo_ReleaseFuncDesc(ITypeInfo *iface, FUNCDESC *pF ...@@ -1070,7 +1070,7 @@ static void WINAPI ScriptTypeInfo_ReleaseFuncDesc(ITypeInfo *iface, FUNCDESC *pF
TRACE("(%p)->(%p)\n", This, pFuncDesc); TRACE("(%p)->(%p)\n", This, pFuncDesc);
heap_free(pFuncDesc); free(pFuncDesc);
} }
static void WINAPI ScriptTypeInfo_ReleaseVarDesc(ITypeInfo *iface, VARDESC *pVarDesc) static void WINAPI ScriptTypeInfo_ReleaseVarDesc(ITypeInfo *iface, VARDESC *pVarDesc)
...@@ -1079,7 +1079,7 @@ static void WINAPI ScriptTypeInfo_ReleaseVarDesc(ITypeInfo *iface, VARDESC *pVar ...@@ -1079,7 +1079,7 @@ static void WINAPI ScriptTypeInfo_ReleaseVarDesc(ITypeInfo *iface, VARDESC *pVar
TRACE("(%p)->(%p)\n", This, pVarDesc); TRACE("(%p)->(%p)\n", This, pVarDesc);
heap_free(pVarDesc); free(pVarDesc);
} }
static const ITypeInfoVtbl ScriptTypeInfoVtbl = { static const ITypeInfoVtbl ScriptTypeInfoVtbl = {
...@@ -1267,9 +1267,9 @@ static ULONG WINAPI ScriptDisp_Release(IDispatchEx *iface) ...@@ -1267,9 +1267,9 @@ static ULONG WINAPI ScriptDisp_Release(IDispatchEx *iface)
release_dynamic_var(This->global_vars[i]); release_dynamic_var(This->global_vars[i]);
heap_pool_free(&This->heap); heap_pool_free(&This->heap);
heap_free(This->global_vars); free(This->global_vars);
heap_free(This->global_funcs); free(This->global_funcs);
heap_free(This); free(This);
} }
return ref; return ref;
...@@ -1297,7 +1297,7 @@ static HRESULT WINAPI ScriptDisp_GetTypeInfo(IDispatchEx *iface, UINT iTInfo, LC ...@@ -1297,7 +1297,7 @@ static HRESULT WINAPI ScriptDisp_GetTypeInfo(IDispatchEx *iface, UINT iTInfo, LC
if(iTInfo) if(iTInfo)
return DISP_E_BADINDEX; return DISP_E_BADINDEX;
if(!(type_info = heap_alloc(sizeof(*type_info)))) if(!(type_info = calloc(1, sizeof(*type_info))))
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
for(i = 0; i < This->global_funcs_cnt; i++) for(i = 0; i < This->global_funcs_cnt; i++)
...@@ -1311,10 +1311,10 @@ static HRESULT WINAPI ScriptDisp_GetTypeInfo(IDispatchEx *iface, UINT iTInfo, LC ...@@ -1311,10 +1311,10 @@ static HRESULT WINAPI ScriptDisp_GetTypeInfo(IDispatchEx *iface, UINT iTInfo, LC
type_info->num_vars = This->global_vars_cnt; type_info->num_vars = This->global_vars_cnt;
type_info->disp = This; type_info->disp = This;
type_info->funcs = heap_alloc(sizeof(*type_info->funcs) * num_funcs); type_info->funcs = calloc(num_funcs, sizeof(*type_info->funcs));
if(!type_info->funcs) if(!type_info->funcs)
{ {
heap_free(type_info); free(type_info);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
...@@ -1508,7 +1508,7 @@ HRESULT create_script_disp(script_ctx_t *ctx, ScriptDisp **ret) ...@@ -1508,7 +1508,7 @@ HRESULT create_script_disp(script_ctx_t *ctx, ScriptDisp **ret)
{ {
ScriptDisp *script_disp; ScriptDisp *script_disp;
script_disp = heap_alloc_zero(sizeof(*script_disp)); script_disp = calloc(1, sizeof(*script_disp));
if(!script_disp) if(!script_disp)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
......
...@@ -183,9 +183,9 @@ static ULONG WINAPI SubMatches_Release(ISubMatches *iface) ...@@ -183,9 +183,9 @@ static ULONG WINAPI SubMatches_Release(ISubMatches *iface)
TRACE("(%p) ref=%ld\n", This, ref); TRACE("(%p) ref=%ld\n", This, ref);
if(!ref) { if(!ref) {
heap_free(This->match); free(This->match);
heap_free(This->result); free(This->result);
heap_free(This); free(This);
} }
return ref; return ref;
...@@ -307,7 +307,7 @@ static HRESULT create_sub_matches(DWORD pos, match_state_t *result, SubMatches * ...@@ -307,7 +307,7 @@ static HRESULT create_sub_matches(DWORD pos, match_state_t *result, SubMatches *
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
ret = heap_alloc_zero(sizeof(*ret)); ret = calloc(1, sizeof(*ret));
if(!ret) if(!ret)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
...@@ -315,9 +315,9 @@ static HRESULT create_sub_matches(DWORD pos, match_state_t *result, SubMatches * ...@@ -315,9 +315,9 @@ static HRESULT create_sub_matches(DWORD pos, match_state_t *result, SubMatches *
ret->result = result; ret->result = result;
if(result) { if(result) {
ret->match = heap_alloc((result->match_len+1) * sizeof(WCHAR)); ret->match = malloc((result->match_len+1) * sizeof(WCHAR));
if(!ret->match) { if(!ret->match) {
heap_free(ret); free(ret);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
memcpy(ret->match, result->cp-result->match_len, result->match_len*sizeof(WCHAR)); memcpy(ret->match, result->cp-result->match_len, result->match_len*sizeof(WCHAR));
...@@ -391,7 +391,7 @@ static ULONG WINAPI Match2_Release(IMatch2 *iface) ...@@ -391,7 +391,7 @@ static ULONG WINAPI Match2_Release(IMatch2 *iface)
if(!ref) { if(!ref) {
ISubMatches_Release(&This->sub_matches->ISubMatches_iface); ISubMatches_Release(&This->sub_matches->ISubMatches_iface);
heap_free(This); free(This);
} }
return ref; return ref;
...@@ -605,14 +605,14 @@ static HRESULT create_match2(DWORD pos, match_state_t **result, IMatch2 **match) ...@@ -605,14 +605,14 @@ static HRESULT create_match2(DWORD pos, match_state_t **result, IMatch2 **match)
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
ret = heap_alloc_zero(sizeof(*ret)); ret = calloc(1, sizeof(*ret));
if(!ret) if(!ret)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
ret->index = pos; ret->index = pos;
hres = create_sub_matches(pos, result ? *result : NULL, &ret->sub_matches); hres = create_sub_matches(pos, result ? *result : NULL, &ret->sub_matches);
if(FAILED(hres)) { if(FAILED(hres)) {
heap_free(ret); free(ret);
return hres; return hres;
} }
if(result) if(result)
...@@ -671,7 +671,7 @@ static ULONG WINAPI MatchCollectionEnum_Release(IEnumVARIANT *iface) ...@@ -671,7 +671,7 @@ static ULONG WINAPI MatchCollectionEnum_Release(IEnumVARIANT *iface)
if(!ref) { if(!ref) {
IMatchCollection2_Release(This->mc); IMatchCollection2_Release(This->mc);
heap_free(This); free(This);
} }
return ref; return ref;
...@@ -754,7 +754,7 @@ static HRESULT create_enum_variant_mc2(IMatchCollection2 *mc, ULONG pos, IEnumVA ...@@ -754,7 +754,7 @@ static HRESULT create_enum_variant_mc2(IMatchCollection2 *mc, ULONG pos, IEnumVA
{ {
MatchCollectionEnum *ret; MatchCollectionEnum *ret;
ret = heap_alloc_zero(sizeof(*ret)); ret = calloc(1, sizeof(*ret));
if(!ret) if(!ret)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
...@@ -827,9 +827,9 @@ static ULONG WINAPI MatchCollection2_Release(IMatchCollection2 *iface) ...@@ -827,9 +827,9 @@ static ULONG WINAPI MatchCollection2_Release(IMatchCollection2 *iface)
for(i=0; i<This->count; i++) for(i=0; i<This->count; i++)
IMatch2_Release(This->matches[i]); IMatch2_Release(This->matches[i]);
heap_free(This->matches); free(This->matches);
heap_free(This); free(This);
} }
return ref; return ref;
...@@ -1024,12 +1024,12 @@ static HRESULT add_match(IMatchCollection2 *iface, IMatch2 *add) ...@@ -1024,12 +1024,12 @@ static HRESULT add_match(IMatchCollection2 *iface, IMatch2 *add)
TRACE("(%p)->(%p)\n", This, add); TRACE("(%p)->(%p)\n", This, add);
if(!This->size) { if(!This->size) {
This->matches = heap_alloc(8*sizeof(IMatch*)); This->matches = malloc(8*sizeof(IMatch*));
if(!This->matches) if(!This->matches)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
This->size = 8; This->size = 8;
}else if(This->size == This->count) { }else if(This->size == This->count) {
IMatch2 **new_matches = heap_realloc(This->matches, 2*This->size*sizeof(IMatch*)); IMatch2 **new_matches = realloc(This->matches, 2*This->size*sizeof(IMatch*));
if(!new_matches) if(!new_matches)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
...@@ -1051,7 +1051,7 @@ static HRESULT create_match_collection2(IMatchCollection2 **match_collection) ...@@ -1051,7 +1051,7 @@ static HRESULT create_match_collection2(IMatchCollection2 **match_collection)
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
ret = heap_alloc_zero(sizeof(*ret)); ret = calloc(1, sizeof(*ret));
if(!ret) if(!ret)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
...@@ -1116,11 +1116,11 @@ static ULONG WINAPI RegExp2_Release(IRegExp2 *iface) ...@@ -1116,11 +1116,11 @@ static ULONG WINAPI RegExp2_Release(IRegExp2 *iface)
TRACE("(%p) ref=%ld\n", This, ref); TRACE("(%p) ref=%ld\n", This, ref);
if(!ref) { if(!ref) {
heap_free(This->pattern); free(This->pattern);
if(This->regexp) if(This->regexp)
regexp_destroy(This->regexp); regexp_destroy(This->regexp);
heap_pool_free(&This->pool); heap_pool_free(&This->pool);
heap_free(This); free(This);
} }
return ref; return ref;
...@@ -1199,7 +1199,7 @@ static HRESULT WINAPI RegExp2_put_Pattern(IRegExp2 *iface, BSTR pattern) ...@@ -1199,7 +1199,7 @@ static HRESULT WINAPI RegExp2_put_Pattern(IRegExp2 *iface, BSTR pattern)
if(pattern && *pattern) { if(pattern && *pattern) {
SIZE_T size = (SysStringLen(pattern)+1) * sizeof(WCHAR); SIZE_T size = (SysStringLen(pattern)+1) * sizeof(WCHAR);
new_pattern = heap_alloc(size); new_pattern = malloc(size);
if(!new_pattern) if(!new_pattern)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
memcpy(new_pattern, pattern, size); memcpy(new_pattern, pattern, size);
...@@ -1207,7 +1207,7 @@ static HRESULT WINAPI RegExp2_put_Pattern(IRegExp2 *iface, BSTR pattern) ...@@ -1207,7 +1207,7 @@ static HRESULT WINAPI RegExp2_put_Pattern(IRegExp2 *iface, BSTR pattern)
new_pattern = NULL; new_pattern = NULL;
} }
heap_free(This->pattern); free(This->pattern);
This->pattern = new_pattern; This->pattern = new_pattern;
if(This->regexp) { if(This->regexp) {
...@@ -1363,13 +1363,13 @@ static HRESULT WINAPI RegExp2_Execute(IRegExp2 *iface, ...@@ -1363,13 +1363,13 @@ static HRESULT WINAPI RegExp2_Execute(IRegExp2 *iface,
hres = regexp_execute(This->regexp, NULL, &This->pool, hres = regexp_execute(This->regexp, NULL, &This->pool,
sourceString, SysStringLen(sourceString), result); sourceString, SysStringLen(sourceString), result);
if(hres != S_OK) { if(hres != S_OK) {
heap_free(result); free(result);
break; break;
} }
pos = result->cp; pos = result->cp;
hres = create_match2(result->cp-result->match_len-sourceString, &result, &add); hres = create_match2(result->cp-result->match_len-sourceString, &result, &add);
heap_free(result); free(result);
if(FAILED(hres)) if(FAILED(hres))
break; break;
hres = add_match(match_collection, add); hres = add_match(match_collection, add);
...@@ -1454,9 +1454,9 @@ static BOOL strbuf_ensure_size(strbuf_t *buf, unsigned len) ...@@ -1454,9 +1454,9 @@ static BOOL strbuf_ensure_size(strbuf_t *buf, unsigned len)
if(new_size < len) if(new_size < len)
new_size = len; new_size = len;
if(buf->buf) if(buf->buf)
new_buf = heap_realloc(buf->buf, new_size*sizeof(WCHAR)); new_buf = realloc(buf->buf, new_size*sizeof(WCHAR));
else else
new_buf = heap_alloc(new_size*sizeof(WCHAR)); new_buf = malloc(new_size*sizeof(WCHAR));
if(!new_buf) if(!new_buf)
return FALSE; return FALSE;
...@@ -1606,7 +1606,7 @@ static HRESULT WINAPI RegExp2_Replace(IRegExp2 *iface, BSTR source, VARIANT repl ...@@ -1606,7 +1606,7 @@ static HRESULT WINAPI RegExp2_Replace(IRegExp2 *iface, BSTR source, VARIANT repl
} }
heap_pool_clear(mark); heap_pool_clear(mark);
heap_free(buf.buf); free(buf.buf);
SysFreeString(replace); SysFreeString(replace);
return hres; return hres;
} }
...@@ -1673,7 +1673,7 @@ BSTR string_replace(BSTR string, BSTR find, BSTR replace, int from, int cnt, int ...@@ -1673,7 +1673,7 @@ BSTR string_replace(BSTR string, BSTR find, BSTR replace, int from, int cnt, int
ret = SysAllocStringLen(buf.buf, buf.len); ret = SysAllocStringLen(buf.buf, buf.len);
} }
heap_free(buf.buf); free(buf.buf);
return ret; return ret;
} }
...@@ -1817,7 +1817,7 @@ HRESULT create_regexp(IDispatch **ret) ...@@ -1817,7 +1817,7 @@ HRESULT create_regexp(IDispatch **ret)
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
regexp = heap_alloc_zero(sizeof(*regexp)); regexp = calloc(1, sizeof(*regexp));
if(!regexp) if(!regexp)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
......
...@@ -111,9 +111,9 @@ static HRESULT exec_global_code(script_ctx_t *ctx, vbscode_t *code, VARIANT *res ...@@ -111,9 +111,9 @@ static HRESULT exec_global_code(script_ctx_t *ctx, vbscode_t *code, VARIANT *res
if (cnt > obj->global_vars_size) if (cnt > obj->global_vars_size)
{ {
if (obj->global_vars) if (obj->global_vars)
new_vars = heap_realloc(obj->global_vars, cnt * sizeof(*new_vars)); new_vars = realloc(obj->global_vars, cnt * sizeof(*new_vars));
else else
new_vars = heap_alloc(cnt * sizeof(*new_vars)); new_vars = malloc(cnt * sizeof(*new_vars));
if (!new_vars) if (!new_vars)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
obj->global_vars = new_vars; obj->global_vars = new_vars;
...@@ -126,9 +126,9 @@ static HRESULT exec_global_code(script_ctx_t *ctx, vbscode_t *code, VARIANT *res ...@@ -126,9 +126,9 @@ static HRESULT exec_global_code(script_ctx_t *ctx, vbscode_t *code, VARIANT *res
if (cnt > obj->global_funcs_size) if (cnt > obj->global_funcs_size)
{ {
if (obj->global_funcs) if (obj->global_funcs)
new_funcs = heap_realloc(obj->global_funcs, cnt * sizeof(*new_funcs)); new_funcs = realloc(obj->global_funcs, cnt * sizeof(*new_funcs));
else else
new_funcs = heap_alloc(cnt * sizeof(*new_funcs)); new_funcs = malloc(cnt * sizeof(*new_funcs));
if (!new_funcs) if (!new_funcs)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
obj->global_funcs = new_funcs; obj->global_funcs = new_funcs;
...@@ -256,8 +256,8 @@ void release_named_item(named_item_t *item) ...@@ -256,8 +256,8 @@ void release_named_item(named_item_t *item)
{ {
if(--item->ref) return; if(--item->ref) return;
heap_free(item->name); free(item->name);
heap_free(item); free(item);
} }
static void release_script(script_ctx_t *ctx) static void release_script(script_ctx_t *ctx)
...@@ -408,9 +408,8 @@ static ULONG WINAPI VBScriptError_Release(IActiveScriptError *iface) ...@@ -408,9 +408,8 @@ static ULONG WINAPI VBScriptError_Release(IActiveScriptError *iface)
TRACE("(%p) ref=%ld\n", This, ref); TRACE("(%p) ref=%ld\n", This, ref);
if(!ref) { if(!ref)
heap_free(This); free(This);
}
return ref; return ref;
} }
...@@ -465,7 +464,7 @@ HRESULT report_script_error(script_ctx_t *ctx, const vbscode_t *code, unsigned l ...@@ -465,7 +464,7 @@ HRESULT report_script_error(script_ctx_t *ctx, const vbscode_t *code, unsigned l
const WCHAR *p, *nl; const WCHAR *p, *nl;
HRESULT hres, result; HRESULT hres, result;
if(!(error = heap_alloc(sizeof(*error)))) if(!(error = malloc(sizeof(*error))))
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
error->IActiveScriptError_iface.lpVtbl = &VBScriptErrorVtbl; error->IActiveScriptError_iface.lpVtbl = &VBScriptErrorVtbl;
...@@ -546,8 +545,8 @@ static ULONG WINAPI VBScript_Release(IActiveScript *iface) ...@@ -546,8 +545,8 @@ static ULONG WINAPI VBScript_Release(IActiveScript *iface)
if(!ref) { if(!ref) {
decrease_state(This, SCRIPTSTATE_CLOSED); decrease_state(This, SCRIPTSTATE_CLOSED);
detach_global_objects(This->ctx); detach_global_objects(This->ctx);
heap_free(This->ctx); free(This->ctx);
heap_free(This); free(This);
} }
return ref; return ref;
...@@ -712,7 +711,7 @@ static HRESULT WINAPI VBScript_AddNamedItem(IActiveScript *iface, LPCOLESTR pstr ...@@ -712,7 +711,7 @@ static HRESULT WINAPI VBScript_AddNamedItem(IActiveScript *iface, LPCOLESTR pstr
} }
} }
item = heap_alloc(sizeof(*item)); item = malloc(sizeof(*item));
if(!item) { if(!item) {
if(disp) if(disp)
IDispatch_Release(disp); IDispatch_Release(disp);
...@@ -723,11 +722,11 @@ static HRESULT WINAPI VBScript_AddNamedItem(IActiveScript *iface, LPCOLESTR pstr ...@@ -723,11 +722,11 @@ static HRESULT WINAPI VBScript_AddNamedItem(IActiveScript *iface, LPCOLESTR pstr
item->disp = disp; item->disp = disp;
item->flags = dwFlags; item->flags = dwFlags;
item->script_obj = NULL; item->script_obj = NULL;
item->name = heap_strdupW(pstrName); item->name = wcsdup(pstrName);
if(!item->name) { if(!item->name) {
if(disp) if(disp)
IDispatch_Release(disp); IDispatch_Release(disp);
heap_free(item); free(item);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
...@@ -1106,7 +1105,7 @@ HRESULT WINAPI VBScriptFactory_CreateInstance(IClassFactory *iface, IUnknown *pU ...@@ -1106,7 +1105,7 @@ HRESULT WINAPI VBScriptFactory_CreateInstance(IClassFactory *iface, IUnknown *pU
TRACE("(%p %s %p)\n", pUnkOuter, debugstr_guid(riid), ppv); TRACE("(%p %s %p)\n", pUnkOuter, debugstr_guid(riid), ppv);
ret = heap_alloc_zero(sizeof(*ret)); ret = calloc(1, sizeof(*ret));
if(!ret) if(!ret)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
...@@ -1119,9 +1118,9 @@ HRESULT WINAPI VBScriptFactory_CreateInstance(IClassFactory *iface, IUnknown *pU ...@@ -1119,9 +1118,9 @@ HRESULT WINAPI VBScriptFactory_CreateInstance(IClassFactory *iface, IUnknown *pU
ret->ref = 1; ret->ref = 1;
ret->state = SCRIPTSTATE_UNINITIALIZED; ret->state = SCRIPTSTATE_UNINITIALIZED;
ctx = ret->ctx = heap_alloc_zero(sizeof(*ctx)); ctx = ret->ctx = calloc(1, sizeof(*ctx));
if(!ctx) { if(!ctx) {
heap_free(ret); free(ret);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
...@@ -1192,7 +1191,7 @@ static ULONG WINAPI AXSite_Release(IServiceProvider *iface) ...@@ -1192,7 +1191,7 @@ static ULONG WINAPI AXSite_Release(IServiceProvider *iface)
TRACE("(%p) ref=%ld\n", This, ref); TRACE("(%p) ref=%ld\n", This, ref);
if(!ref) if(!ref)
heap_free(This); free(This);
return ref; return ref;
} }
...@@ -1226,7 +1225,7 @@ IUnknown *create_ax_site(script_ctx_t *ctx) ...@@ -1226,7 +1225,7 @@ IUnknown *create_ax_site(script_ctx_t *ctx)
return NULL; return NULL;
} }
ret = heap_alloc(sizeof(*ret)); ret = malloc(sizeof(*ret));
if(!ret) { if(!ret) {
IServiceProvider_Release(sp); IServiceProvider_Release(sp);
return NULL; return NULL;
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#include "vbscript_classes.h" #include "vbscript_classes.h"
#include "vbscript_defs.h" #include "vbscript_defs.h"
#include "wine/heap.h"
#include "wine/list.h" #include "wine/list.h"
typedef struct { typedef struct {
...@@ -413,22 +412,6 @@ HRESULT WINAPI VBScriptRegExpFactory_CreateInstance(IClassFactory*,IUnknown*,REF ...@@ -413,22 +412,6 @@ HRESULT WINAPI VBScriptRegExpFactory_CreateInstance(IClassFactory*,IUnknown*,REF
BSTR get_vbscript_string(int) DECLSPEC_HIDDEN; BSTR get_vbscript_string(int) DECLSPEC_HIDDEN;
static inline LPWSTR heap_strdupW(LPCWSTR str)
{
LPWSTR ret = NULL;
if(str) {
DWORD size;
size = (lstrlenW(str)+1)*sizeof(WCHAR);
ret = heap_alloc(size);
if(ret)
memcpy(ret, str, size);
}
return ret;
}
#define VBSCRIPT_BUILD_VERSION 16978 #define VBSCRIPT_BUILD_VERSION 16978
#define VBSCRIPT_MAJOR_VERSION 5 #define VBSCRIPT_MAJOR_VERSION 5
#define VBSCRIPT_MINOR_VERSION 8 #define VBSCRIPT_MINOR_VERSION 8
...@@ -66,12 +66,12 @@ void *heap_pool_alloc(heap_pool_t *heap, size_t size) ...@@ -66,12 +66,12 @@ void *heap_pool_alloc(heap_pool_t *heap, size_t size)
if(!heap->block_cnt) { if(!heap->block_cnt) {
if(!heap->blocks) { if(!heap->blocks) {
heap->blocks = heap_alloc(sizeof(void*)); heap->blocks = malloc(sizeof(void*));
if(!heap->blocks) if(!heap->blocks)
return NULL; return NULL;
} }
tmp = heap_alloc(block_size(0)); tmp = malloc(block_size(0));
if(!tmp) if(!tmp)
return NULL; return NULL;
...@@ -87,12 +87,12 @@ void *heap_pool_alloc(heap_pool_t *heap, size_t size) ...@@ -87,12 +87,12 @@ void *heap_pool_alloc(heap_pool_t *heap, size_t size)
if(size <= block_size(heap->last_block+1)) { if(size <= block_size(heap->last_block+1)) {
if(heap->last_block+1 == heap->block_cnt) { if(heap->last_block+1 == heap->block_cnt) {
tmp = heap_realloc(heap->blocks, (heap->block_cnt+1)*sizeof(void*)); tmp = realloc(heap->blocks, (heap->block_cnt+1)*sizeof(void*));
if(!tmp) if(!tmp)
return NULL; return NULL;
heap->blocks = tmp; heap->blocks = tmp;
heap->blocks[heap->block_cnt] = heap_alloc(block_size(heap->block_cnt)); heap->blocks[heap->block_cnt] = malloc(block_size(heap->block_cnt));
if(!heap->blocks[heap->block_cnt]) if(!heap->blocks[heap->block_cnt])
return NULL; return NULL;
...@@ -104,7 +104,7 @@ void *heap_pool_alloc(heap_pool_t *heap, size_t size) ...@@ -104,7 +104,7 @@ void *heap_pool_alloc(heap_pool_t *heap, size_t size)
return heap->blocks[heap->last_block]; return heap->blocks[heap->last_block];
} }
list = heap_alloc(size + sizeof(struct list)); list = malloc(size + sizeof(struct list));
if(!list) if(!list)
return NULL; return NULL;
...@@ -137,7 +137,7 @@ void heap_pool_clear(heap_pool_t *heap) ...@@ -137,7 +137,7 @@ void heap_pool_clear(heap_pool_t *heap)
while((tmp = list_next(&heap->custom_blocks, &heap->custom_blocks))) { while((tmp = list_next(&heap->custom_blocks, &heap->custom_blocks))) {
list_remove(tmp); list_remove(tmp);
heap_free(tmp); free(tmp);
} }
if(WARN_ON(heap)) { if(WARN_ON(heap)) {
...@@ -158,8 +158,8 @@ void heap_pool_free(heap_pool_t *heap) ...@@ -158,8 +158,8 @@ void heap_pool_free(heap_pool_t *heap)
heap_pool_clear(heap); heap_pool_clear(heap);
for(i=0; i < heap->block_cnt; i++) for(i=0; i < heap->block_cnt; i++)
heap_free(heap->blocks[i]); free(heap->blocks[i]);
heap_free(heap->blocks); free(heap->blocks);
heap_pool_init(heap); heap_pool_init(heap);
} }
......
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