Jacek Caban : shdocvw: Wrap Heap* finctions by inline functions.

Alexandre Julliard julliard at wine.codeweavers.com
Mon May 15 07:35:46 CDT 2006


Module: wine
Branch: refs/heads/master
Commit: e718939ebdce7e077636e6bee5dfc6dfaf4cdab4
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=e718939ebdce7e077636e6bee5dfc6dfaf4cdab4

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Thu May 11 06:45:43 2006 +0200

shdocvw: Wrap Heap* finctions by inline functions.

---

 dlls/shdocvw/events.c       |   12 ++++++------
 dlls/shdocvw/ie.c           |    2 +-
 dlls/shdocvw/iexplore.c     |    8 ++++----
 dlls/shdocvw/navigate.c     |    8 ++++----
 dlls/shdocvw/shdocvw.h      |   17 +++++++++++++++++
 dlls/shdocvw/shdocvw_main.c |    4 ++--
 dlls/shdocvw/shlinstobj.c   |   14 +++++++-------
 dlls/shdocvw/webbrowser.c   |    6 +++---
 8 files changed, 44 insertions(+), 27 deletions(-)

diff --git a/dlls/shdocvw/events.c b/dlls/shdocvw/events.c
index e6541f9..8d35728 100644
--- a/dlls/shdocvw/events.c
+++ b/dlls/shdocvw/events.c
@@ -206,10 +206,10 @@ static HRESULT WINAPI ConnectionPoint_Ad
         }
 
         if(i == This->sinks_size)
-            This->sinks = HeapReAlloc(GetProcessHeap(), 0, This->sinks,
-                                      (++This->sinks_size)*sizeof(*This->sinks));
+            This->sinks = shdocvw_realloc(This->sinks,
+                                          (++This->sinks_size)*sizeof(*This->sinks));
     }else {
-        This->sinks = HeapAlloc(GetProcessHeap(), 0, sizeof(*This->sinks));
+        This->sinks = shdocvw_alloc(sizeof(*This->sinks));
         This->sinks_size = 1;
         i = 0;
     }
@@ -270,7 +270,7 @@ void call_sink(ConnectionPoint *This, DI
 
 static void ConnectionPoint_Create(DocHost *doc_host, REFIID riid, ConnectionPoint **cp)
 {
-    ConnectionPoint *ret = HeapAlloc(GetProcessHeap(), 0, sizeof(ConnectionPoint));
+    ConnectionPoint *ret = shdocvw_alloc(sizeof(ConnectionPoint));
 
     ret->lpConnectionPointVtbl = &ConnectionPointVtbl;
 
@@ -293,8 +293,8 @@ static void ConnectionPoint_Destroy(Conn
             IDispatch_Release(This->sinks[i]);
     }
 
-    HeapFree(GetProcessHeap(), 0, This->sinks);
-    HeapFree(GetProcessHeap(), 0, This);
+    shdocvw_free(This->sinks);
+    shdocvw_free(This);
 }
 
 void DocHost_Events_Init(DocHost *This)
diff --git a/dlls/shdocvw/ie.c b/dlls/shdocvw/ie.c
index 857241f..354ad3c 100644
--- a/dlls/shdocvw/ie.c
+++ b/dlls/shdocvw/ie.c
@@ -72,7 +72,7 @@ static ULONG WINAPI InternetExplorer_Rel
 
     if(!ref) {
         DocHost_Release(&This->doc_host);
-        HeapFree(GetProcessHeap(), 0, This);
+        shdocvw_free(This);
     }
 
     return ref;
diff --git a/dlls/shdocvw/iexplore.c b/dlls/shdocvw/iexplore.c
index 91548fd..a78255e 100644
--- a/dlls/shdocvw/iexplore.c
+++ b/dlls/shdocvw/iexplore.c
@@ -149,7 +149,7 @@ HRESULT InternetExplorer_Create(IUnknown
 
     TRACE("(%p %s %p)\n", pOuter, debugstr_guid(riid), ppv);
 
-    ret = HeapAlloc(GetProcessHeap(), 0, sizeof(InternetExplorer));
+    ret = shdocvw_alloc(sizeof(InternetExplorer));
     ret->ref = 0;
 
     ret->doc_host.disp = (IDispatch*)WEBBROWSER2(ret);
@@ -162,7 +162,7 @@ HRESULT InternetExplorer_Create(IUnknown
 
     hres = IWebBrowser2_QueryInterface(WEBBROWSER2(ret), riid, ppv);
     if(FAILED(hres)) {
-        HeapFree(GetProcessHeap(), 0, ret);
+        shdocvw_free(ret);
         return hres;
     }
 
@@ -195,12 +195,12 @@ DWORD WINAPI IEWinMain(LPSTR szCommandLi
         DWORD len;
 
         len = MultiByteToWideChar(CP_ACP, 0, szCommandLine, -1, NULL, 0);
-        url = HeapAlloc(GetProcessHeap(),0,len*sizeof(WCHAR));
+        url = shdocvw_alloc(len*sizeof(WCHAR));
         MultiByteToWideChar(CP_ACP, 0, szCommandLine, -1, url, len);
 
         wb = create_ie_window(url);
 
-        HeapFree(GetProcessHeap(), 0, url);
+        shdocvw_free(url);
     }
 
     /* run the message loop for this thread */
diff --git a/dlls/shdocvw/navigate.c b/dlls/shdocvw/navigate.c
index 5798ead..9998624 100644
--- a/dlls/shdocvw/navigate.c
+++ b/dlls/shdocvw/navigate.c
@@ -137,8 +137,8 @@ static ULONG WINAPI BindStatusCallback_R
     if(!ref) {
         if(This->post_data)
             GlobalFree(This->post_data);
-        HeapFree(GetProcessHeap(), 0, This->headers);
-        HeapFree(GetProcessHeap(), 0, This);
+        shdocvw_free(This->headers);
+        shdocvw_free(This);
     }
 
     return ref;
@@ -293,7 +293,7 @@ static const IHttpNegotiateVtbl HttpNego
 static IBindStatusCallback *create_callback(DocHost *This, PBYTE post_data,
         ULONG post_data_len, LPWSTR headers, VARIANT_BOOL *cancel)
 {
-    BindStatusCallback *ret = HeapAlloc(GetProcessHeap(), 0, sizeof(BindStatusCallback));
+    BindStatusCallback *ret = shdocvw_alloc(sizeof(BindStatusCallback));
 
     ret->lpBindStatusCallbackVtbl = &BindStatusCallbackVtbl;
     ret->lpHttpNegotiateVtbl      = &HttpNegotiateVtbl;
@@ -310,7 +310,7 @@ static IBindStatusCallback *create_callb
 
     if(headers) {
         int size = (strlenW(headers)+1)*sizeof(WCHAR);
-        ret->headers = HeapAlloc(GetProcessHeap(), 0, size);
+        ret->headers = shdocvw_alloc(size);
         memcpy(ret->headers, headers, size);
     }
 
diff --git a/dlls/shdocvw/shdocvw.h b/dlls/shdocvw/shdocvw.h
index 49fb9cb..0279aca 100644
--- a/dlls/shdocvw/shdocvw.h
+++ b/dlls/shdocvw/shdocvw.h
@@ -207,4 +207,21 @@ extern void unregister_iewindow_class(vo
 
 HRESULT register_class_object(BOOL);
 
+/* memory allocation functions */
+
+static inline void *shdocvw_alloc(size_t len)
+{
+    return HeapAlloc(GetProcessHeap(), 0, len);
+}
+
+static inline void *shdocvw_realloc(void *mem, size_t len)
+{
+    return HeapReAlloc(GetProcessHeap(), 0, mem, len);
+}
+
+static inline BOOL shdocvw_free(void *mem)
+{
+    return HeapFree(GetProcessHeap(), 0, mem);
+}
+
 #endif /* __WINE_SHDOCVW_H */
diff --git a/dlls/shdocvw/shdocvw_main.c b/dlls/shdocvw/shdocvw_main.c
index 0093243..206f457 100644
--- a/dlls/shdocvw/shdocvw_main.c
+++ b/dlls/shdocvw/shdocvw_main.c
@@ -180,7 +180,7 @@ static ULONG WINAPI dlRelease( IBindStat
     if( !ref )
     {
         DestroyWindow( This->hDialog );
-        HeapFree( GetProcessHeap(), 0, This );
+        shdocvw_free(This);
     }
 
     SHDOCVW_UnlockModule();
@@ -285,7 +285,7 @@ static IBindStatusCallback* create_dl(HW
 {
     IBindStatusCallbackImpl *This;
 
-    This = HeapAlloc( GetProcessHeap(), 0, sizeof *This );
+    This = shdocvw_alloc(sizeof(*This));
     This->vtbl = &dlVtbl;
     This->ref = 1;
     This->hDialog = dlg;
diff --git a/dlls/shdocvw/shlinstobj.c b/dlls/shdocvw/shlinstobj.c
index 19ba3b8..09f31dd 100644
--- a/dlls/shdocvw/shlinstobj.c
+++ b/dlls/shdocvw/shlinstobj.c
@@ -60,7 +60,7 @@ static void RegistryPropertyBag_Destroy(
     TRACE("This=%p)\n", This);
 
     RegCloseKey(This->m_hInitPropertyBagKey);
-    HeapFree(GetProcessHeap(), 0, This);
+    shdocvw_free(This);
 }
 
 static HRESULT WINAPI RegistryPropertyBag_IPropertyBag_QueryInterface(IPropertyBag *iface,
@@ -131,20 +131,20 @@ static HRESULT WINAPI RegistryPropertyBa
     if (res != ERROR_SUCCESS) 
         return E_INVALIDARG;
 
-    pwszValue = HeapAlloc(GetProcessHeap(), 0, cbData);
+    pwszValue = shdocvw_alloc(cbData);
     if (!pwszValue)
         return E_OUTOFMEMORY;
  
     res = RegQueryValueExW(This->m_hInitPropertyBagKey, pwszPropName, NULL, &dwType, 
                            (LPBYTE)pwszValue, &cbData);
     if (res != ERROR_SUCCESS) {
-        HeapFree(GetProcessHeap(), 0, pwszValue);
+        shdocvw_free(pwszValue);
         return E_INVALIDARG;
     }
 
     V_VT(pVar) = VT_BSTR;
     V_BSTR(pVar) = SysAllocString(pwszValue);
-    HeapFree(GetProcessHeap(), 0, pwszValue);
+    shdocvw_free(pwszValue);
 
     if (vtDst != VT_BSTR) {
         hr = VariantChangeTypeEx(pVar, pVar, LOCALE_SYSTEM_DEFAULT, 0, vtDst);
@@ -177,7 +177,7 @@ HRESULT RegistryPropertyBag_Constructor(
     TRACE("(hInitPropertyBagKey=%p, riid=%s, ppvObject=%p)\n", hInitPropertyBagKey, 
         debugstr_guid(riid), ppvObject);
     
-    pRegistryPropertyBag = HeapAlloc(GetProcessHeap(), 0, sizeof(RegistryPropertyBag));
+    pRegistryPropertyBag = shdocvw_alloc(sizeof(RegistryPropertyBag));
     if (pRegistryPropertyBag) {
         pRegistryPropertyBag->lpIPropertyBagVtbl = &RegistryPropertyBag_IPropertyBagVtbl;
         pRegistryPropertyBag->m_cRef = 0;
@@ -207,7 +207,7 @@ typedef struct _InstanceObjectFactory {
 
 static void InstanceObjectFactory_Destroy(InstanceObjectFactory *This) {
     IPropertyBag_Release(This->m_pPropertyBag);
-    HeapFree(GetProcessHeap(), 0, This);
+    shdocvw_free(This);
 }
 
 static HRESULT WINAPI InstanceObjectFactory_IClassFactory_QueryInterface(IClassFactory *iface, 
@@ -323,7 +323,7 @@ HRESULT InstanceObjectFactory_Constructo
     TRACE("(RegistryPropertyBag=%p, riid=%s, ppvObject=%p)\n", pPropertyBag,
         debugstr_guid(riid), ppvObject);
 
-    pInstanceObjectFactory = HeapAlloc(GetProcessHeap(), 0, sizeof(InstanceObjectFactory));
+    pInstanceObjectFactory = shdocvw_alloc(sizeof(InstanceObjectFactory));
     if (pInstanceObjectFactory) {
         pInstanceObjectFactory->lpIClassFactoryVtbl = &InstanceObjectFactory_IClassFactoryVtbl;
         pInstanceObjectFactory->m_cRef = 0;
diff --git a/dlls/shdocvw/webbrowser.c b/dlls/shdocvw/webbrowser.c
index d50bbf3..3b319de 100644
--- a/dlls/shdocvw/webbrowser.c
+++ b/dlls/shdocvw/webbrowser.c
@@ -133,7 +133,7 @@ static ULONG WINAPI WebBrowser_Release(I
 
         WebBrowser_OleObject_Destroy(This);
 
-        HeapFree(GetProcessHeap(), 0, This);
+        shdocvw_free(This);
         SHDOCVW_UnlockModule();
     }
 
@@ -925,7 +925,7 @@ HRESULT WebBrowser_Create(IUnknown *pOut
 
     TRACE("(%p %s %p)\n", pOuter, debugstr_guid(riid), ppv);
 
-    ret = HeapAlloc(GetProcessHeap(), 0, sizeof(WebBrowser));
+    ret = shdocvw_alloc(sizeof(WebBrowser));
 
     ret->lpWebBrowser2Vtbl = &WebBrowser2Vtbl;
     ret->ref = 0;
@@ -949,7 +949,7 @@ HRESULT WebBrowser_Create(IUnknown *pOut
     if(SUCCEEDED(hres)) {
         SHDOCVW_LockModule();
     }else {
-        HeapFree(GetProcessHeap(), 0, ret);
+        shdocvw_free(ret);
         return hres;
     }
 




More information about the wine-cvs mailing list