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