[PATCH 2/2] vbscript: Use the global HeapAlloc() wrappers

Michael Stefaniuc mstefani at winehq.org
Sun Jan 21 15:05:35 CST 2018


Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
---
I did not bother to find the locations where the _nofail variants
can be used. Will start working on that stuff only after the patch
implementing the generic HeapAlloc wrappers is in.



 dlls/vbscript/interp.c   |  6 +++---
 dlls/vbscript/vbdisp.c   |  8 ++++----
 dlls/vbscript/vbregexp.c | 10 +++++-----
 dlls/vbscript/vbscript.c |  4 ++--
 dlls/vbscript/vbscript.h | 21 +--------------------
 5 files changed, 15 insertions(+), 34 deletions(-)

diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c
index 9ec329924c..8853ef9ee5 100644
--- a/dlls/vbscript/interp.c
+++ b/dlls/vbscript/interp.c
@@ -1034,7 +1034,7 @@ static HRESULT interp_dim(exec_ctx_t *ctx)
 
     assert(array_id < ctx->func->array_cnt);
     if(!ctx->arrays) {
-        ctx->arrays = heap_alloc_zero(ctx->func->array_cnt * sizeof(SAFEARRAY*));
+        ctx->arrays = heap_calloc(ctx->func->array_cnt, sizeof(SAFEARRAY*));
         if(!ctx->arrays)
             return E_OUTOFMEMORY;
     }
@@ -2087,7 +2087,7 @@ HRESULT exec_script(script_ctx_t *ctx, function_t *func, vbdisp_t *vbthis, DISPP
         VARIANT *v;
         unsigned i;
 
-        exec.args = heap_alloc_zero(func->arg_cnt * sizeof(VARIANT));
+        exec.args = heap_calloc(func->arg_cnt, sizeof(VARIANT));
         if(!exec.args) {
             release_exec(&exec);
             return E_OUTOFMEMORY;
@@ -2113,7 +2113,7 @@ HRESULT exec_script(script_ctx_t *ctx, function_t *func, vbdisp_t *vbthis, DISPP
     }
 
     if(func->var_cnt) {
-        exec.vars = heap_alloc_zero(func->var_cnt * sizeof(VARIANT));
+        exec.vars = heap_calloc(func->var_cnt, sizeof(VARIANT));
         if(!exec.vars) {
             release_exec(&exec);
             return E_OUTOFMEMORY;
diff --git a/dlls/vbscript/vbdisp.c b/dlls/vbscript/vbdisp.c
index 9c0c4c1d9a..714bab6e05 100644
--- a/dlls/vbscript/vbdisp.c
+++ b/dlls/vbscript/vbdisp.c
@@ -564,7 +564,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 = heap_zalloc( offsetof( vbdisp_t, props[desc->prop_cnt] ));
     if(!vbdisp)
         return E_OUTOFMEMORY;
 
@@ -575,7 +575,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 = heap_calloc(desc->array_cnt, sizeof(*vbdisp->arrays));
         if(vbdisp->arrays) {
             unsigned i, j;
 
@@ -642,7 +642,7 @@ HRESULT create_procedure_disp(script_ctx_t *ctx, vbscode_t *code, IDispatch **re
     vbdisp_t *vbdisp;
     HRESULT hres;
 
-    desc = heap_alloc_zero(sizeof(*desc));
+    desc = heap_zalloc(sizeof(*desc));
     if(!desc)
         return E_OUTOFMEMORY;
 
@@ -960,7 +960,7 @@ HRESULT create_script_disp(script_ctx_t *ctx, ScriptDisp **ret)
 {
     ScriptDisp *script_disp;
 
-    script_disp = heap_alloc_zero(sizeof(*script_disp));
+    script_disp = heap_zalloc(sizeof(*script_disp));
     if(!script_disp)
         return E_OUTOFMEMORY;
 
diff --git a/dlls/vbscript/vbregexp.c b/dlls/vbscript/vbregexp.c
index 800ea5e74f..ad0f60944c 100644
--- a/dlls/vbscript/vbregexp.c
+++ b/dlls/vbscript/vbregexp.c
@@ -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 = heap_zalloc(sizeof(*ret));
     if(!ret)
         return E_OUTOFMEMORY;
 
@@ -605,7 +605,7 @@ static HRESULT create_match2(DWORD pos, match_state_t **result, IMatch2 **match)
     if(FAILED(hres))
         return hres;
 
-    ret = heap_alloc_zero(sizeof(*ret));
+    ret = heap_zalloc(sizeof(*ret));
     if(!ret)
         return E_OUTOFMEMORY;
 
@@ -754,7 +754,7 @@ static HRESULT create_enum_variant_mc2(IMatchCollection2 *mc, ULONG pos, IEnumVA
 {
     MatchCollectionEnum *ret;
 
-    ret = heap_alloc_zero(sizeof(*ret));
+    ret = heap_zalloc(sizeof(*ret));
     if(!ret)
         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 = heap_zalloc(sizeof(*ret));
     if(!ret)
         return E_OUTOFMEMORY;
 
@@ -1602,7 +1602,7 @@ HRESULT create_regexp(IDispatch **ret)
     if(FAILED(hres))
         return hres;
 
-    regexp = heap_alloc_zero(sizeof(*regexp));
+    regexp = heap_zalloc(sizeof(*regexp));
     if(!regexp)
         return E_OUTOFMEMORY;
 
diff --git a/dlls/vbscript/vbscript.c b/dlls/vbscript/vbscript.c
index 645068e347..1aae7f23a9 100644
--- a/dlls/vbscript/vbscript.c
+++ b/dlls/vbscript/vbscript.c
@@ -565,7 +565,7 @@ static HRESULT WINAPI VBScriptParse_InitNew(IActiveScriptParse *iface)
     if(This->ctx)
         return E_UNEXPECTED;
 
-    ctx = heap_alloc_zero(sizeof(script_ctx_t));
+    ctx = heap_zalloc(sizeof(script_ctx_t));
     if(!ctx)
         return E_OUTOFMEMORY;
 
@@ -757,7 +757,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 = heap_zalloc(sizeof(*ret));
     if(!ret)
         return E_OUTOFMEMORY;
 
diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h
index ec41737083..5e935ff76a 100644
--- a/dlls/vbscript/vbscript.h
+++ b/dlls/vbscript/vbscript.h
@@ -28,6 +28,7 @@
 
 #include "vbscript_classes.h"
 
+#include "wine/heap.h"
 #include "wine/list.h"
 #include "wine/unicode.h"
 
@@ -430,26 +431,6 @@ HRESULT create_safearray_iter(SAFEARRAY *sa, IEnumVARIANT **ev) DECLSPEC_HIDDEN;
 HRESULT WINAPI VBScriptFactory_CreateInstance(IClassFactory*,IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
 HRESULT WINAPI VBScriptRegExpFactory_CreateInstance(IClassFactory*,IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
 
-static inline void* __WINE_ALLOC_SIZE(1) heap_alloc(size_t size)
-{
-    return HeapAlloc(GetProcessHeap(), 0, size);
-}
-
-static inline void* __WINE_ALLOC_SIZE(1) heap_alloc_zero(size_t size)
-{
-    return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
-}
-
-static inline void* __WINE_ALLOC_SIZE(2) heap_realloc(void *mem, size_t size)
-{
-    return HeapReAlloc(GetProcessHeap(), 0, mem, size);
-}
-
-static inline BOOL heap_free(void *mem)
-{
-    return HeapFree(GetProcessHeap(), 0, mem);
-}
-
 static inline LPWSTR heap_strdupW(LPCWSTR str)
 {
     LPWSTR ret = NULL;
-- 
2.14.3




More information about the wine-devel mailing list