Jacek Caban : mshtml: Moved global property allocation to separated function.

Alexandre Julliard julliard at winehq.org
Tue Nov 3 15:37:18 CST 2009


Module: wine
Branch: master
Commit: 9195e1b7568711ea502c9f9b0bc555acd6ee1e72
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=9195e1b7568711ea502c9f9b0bc555acd6ee1e72

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Sun Nov  1 19:21:37 2009 +0100

mshtml: Moved global property allocation to separated function.

---

 dlls/mshtml/htmlwindow.c |   58 +++++++++++++++++++++++++++++----------------
 1 files changed, 37 insertions(+), 21 deletions(-)

diff --git a/dlls/mshtml/htmlwindow.c b/dlls/mshtml/htmlwindow.c
index b278a5c..a14fe5c 100644
--- a/dlls/mshtml/htmlwindow.c
+++ b/dlls/mshtml/htmlwindow.c
@@ -1399,6 +1399,37 @@ static HRESULT WINAPI WindowDispEx_Invoke(IDispatchEx *iface, DISPID dispIdMembe
                               pVarResult, pExcepInfo, puArgErr);
 }
 
+static global_prop_t *alloc_global_prop(HTMLWindow *This, BSTR name)
+{
+    if(This->global_prop_cnt == This->global_prop_size) {
+        global_prop_t *new_props;
+        DWORD new_size;
+
+        if(This->global_props) {
+            new_size = This->global_prop_size*2;
+            new_props = heap_realloc(This->global_props, new_size*sizeof(global_prop_t));
+        }else {
+            new_size = 16;
+            new_props = heap_alloc(new_size*sizeof(global_prop_t));
+        }
+        if(!new_props)
+            return NULL;
+        This->global_props = new_props;
+        This->global_prop_size = new_size;
+    }
+
+    This->global_props[This->global_prop_cnt].name = heap_strdupW(name);
+    if(!This->global_props[This->global_prop_cnt].name)
+        return NULL;
+
+    return This->global_props + This->global_prop_cnt++;
+}
+
+static inline DWORD prop_to_dispid(HTMLWindow *This, global_prop_t *prop)
+{
+    return MSHTML_DISPID_CUSTOM_MIN + (prop-This->global_props);
+}
+
 static HRESULT WINAPI WindowDispEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
 {
     HTMLWindow *This = DISPEX_THIS(iface);
@@ -1417,31 +1448,16 @@ static HRESULT WINAPI WindowDispEx_GetDispID(IDispatchEx *iface, BSTR bstrName,
     }
 
     if(find_global_prop(This, bstrName, grfdex, &script_host, &id)) {
-        if(This->global_prop_cnt == This->global_prop_size) {
-            global_prop_t *new_props;
-            DWORD new_size;
-
-            if(This->global_props) {
-                new_size = This->global_prop_size*2;
-                new_props = heap_realloc(This->global_props, new_size*sizeof(global_prop_t));
-            }else {
-                new_size = 16;
-                new_props = heap_alloc(new_size*sizeof(global_prop_t));
-            }
-            if(!new_props)
-                return E_OUTOFMEMORY;
-            This->global_props = new_props;
-            This->global_prop_size = new_size;
-        }
+        global_prop_t *prop;
 
-        This->global_props[This->global_prop_cnt].name = heap_strdupW(bstrName);
-        if(!This->global_props[This->global_prop_cnt].name)
+        prop = alloc_global_prop(This, bstrName);
+        if(!prop)
             return E_OUTOFMEMORY;
 
-        This->global_props[This->global_prop_cnt].script_host = script_host;
-        This->global_props[This->global_prop_cnt].id = id;
+        prop->script_host = script_host;
+        prop->id = id;
 
-        *pid = MSHTML_DISPID_CUSTOM_MIN + (This->global_prop_cnt++);
+        *pid = prop_to_dispid(This, prop);
         return S_OK;
     }
 




More information about the wine-cvs mailing list