shdocvw: Wrap Heap* finctions by inline functions.

This commit is contained in:
Jacek Caban 2006-05-11 06:45:43 +02:00 committed by Alexandre Julliard
parent 3dce323d69
commit e718939ebd
8 changed files with 44 additions and 27 deletions

View File

@ -206,10 +206,10 @@ static HRESULT WINAPI ConnectionPoint_Advise(IConnectionPoint *iface, IUnknown *
} }
if(i == This->sinks_size) if(i == This->sinks_size)
This->sinks = HeapReAlloc(GetProcessHeap(), 0, This->sinks, This->sinks = shdocvw_realloc(This->sinks,
(++This->sinks_size)*sizeof(*This->sinks)); (++This->sinks_size)*sizeof(*This->sinks));
}else { }else {
This->sinks = HeapAlloc(GetProcessHeap(), 0, sizeof(*This->sinks)); This->sinks = shdocvw_alloc(sizeof(*This->sinks));
This->sinks_size = 1; This->sinks_size = 1;
i = 0; i = 0;
} }
@ -270,7 +270,7 @@ void call_sink(ConnectionPoint *This, DISPID dispid, DISPPARAMS *dispparams)
static void ConnectionPoint_Create(DocHost *doc_host, REFIID riid, ConnectionPoint **cp) 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; ret->lpConnectionPointVtbl = &ConnectionPointVtbl;
@ -293,8 +293,8 @@ static void ConnectionPoint_Destroy(ConnectionPoint *This)
IDispatch_Release(This->sinks[i]); IDispatch_Release(This->sinks[i]);
} }
HeapFree(GetProcessHeap(), 0, This->sinks); shdocvw_free(This->sinks);
HeapFree(GetProcessHeap(), 0, This); shdocvw_free(This);
} }
void DocHost_Events_Init(DocHost *This) void DocHost_Events_Init(DocHost *This)

View File

@ -72,7 +72,7 @@ static ULONG WINAPI InternetExplorer_Release(IWebBrowser2 *iface)
if(!ref) { if(!ref) {
DocHost_Release(&This->doc_host); DocHost_Release(&This->doc_host);
HeapFree(GetProcessHeap(), 0, This); shdocvw_free(This);
} }
return ref; return ref;

View File

@ -149,7 +149,7 @@ HRESULT InternetExplorer_Create(IUnknown *pOuter, REFIID riid, void **ppv)
TRACE("(%p %s %p)\n", pOuter, debugstr_guid(riid), ppv); 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->ref = 0;
ret->doc_host.disp = (IDispatch*)WEBBROWSER2(ret); ret->doc_host.disp = (IDispatch*)WEBBROWSER2(ret);
@ -162,7 +162,7 @@ HRESULT InternetExplorer_Create(IUnknown *pOuter, REFIID riid, void **ppv)
hres = IWebBrowser2_QueryInterface(WEBBROWSER2(ret), riid, ppv); hres = IWebBrowser2_QueryInterface(WEBBROWSER2(ret), riid, ppv);
if(FAILED(hres)) { if(FAILED(hres)) {
HeapFree(GetProcessHeap(), 0, ret); shdocvw_free(ret);
return hres; return hres;
} }
@ -195,12 +195,12 @@ DWORD WINAPI IEWinMain(LPSTR szCommandLine, int nShowWindow)
DWORD len; DWORD len;
len = MultiByteToWideChar(CP_ACP, 0, szCommandLine, -1, NULL, 0); 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); MultiByteToWideChar(CP_ACP, 0, szCommandLine, -1, url, len);
wb = create_ie_window(url); wb = create_ie_window(url);
HeapFree(GetProcessHeap(), 0, url); shdocvw_free(url);
} }
/* run the message loop for this thread */ /* run the message loop for this thread */

View File

@ -137,8 +137,8 @@ static ULONG WINAPI BindStatusCallback_Release(IBindStatusCallback *iface)
if(!ref) { if(!ref) {
if(This->post_data) if(This->post_data)
GlobalFree(This->post_data); GlobalFree(This->post_data);
HeapFree(GetProcessHeap(), 0, This->headers); shdocvw_free(This->headers);
HeapFree(GetProcessHeap(), 0, This); shdocvw_free(This);
} }
return ref; return ref;
@ -293,7 +293,7 @@ static const IHttpNegotiateVtbl HttpNegotiateVtbl = {
static IBindStatusCallback *create_callback(DocHost *This, PBYTE post_data, static IBindStatusCallback *create_callback(DocHost *This, PBYTE post_data,
ULONG post_data_len, LPWSTR headers, VARIANT_BOOL *cancel) 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->lpBindStatusCallbackVtbl = &BindStatusCallbackVtbl;
ret->lpHttpNegotiateVtbl = &HttpNegotiateVtbl; ret->lpHttpNegotiateVtbl = &HttpNegotiateVtbl;
@ -310,7 +310,7 @@ static IBindStatusCallback *create_callback(DocHost *This, PBYTE post_data,
if(headers) { if(headers) {
int size = (strlenW(headers)+1)*sizeof(WCHAR); int size = (strlenW(headers)+1)*sizeof(WCHAR);
ret->headers = HeapAlloc(GetProcessHeap(), 0, size); ret->headers = shdocvw_alloc(size);
memcpy(ret->headers, headers, size); memcpy(ret->headers, headers, size);
} }

View File

@ -207,4 +207,21 @@ extern void unregister_iewindow_class(void);
HRESULT register_class_object(BOOL); 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 */ #endif /* __WINE_SHDOCVW_H */

View File

@ -180,7 +180,7 @@ static ULONG WINAPI dlRelease( IBindStatusCallback* iface )
if( !ref ) if( !ref )
{ {
DestroyWindow( This->hDialog ); DestroyWindow( This->hDialog );
HeapFree( GetProcessHeap(), 0, This ); shdocvw_free(This);
} }
SHDOCVW_UnlockModule(); SHDOCVW_UnlockModule();
@ -285,7 +285,7 @@ static IBindStatusCallback* create_dl(HWND dlg, BOOL *pbCancelled)
{ {
IBindStatusCallbackImpl *This; IBindStatusCallbackImpl *This;
This = HeapAlloc( GetProcessHeap(), 0, sizeof *This ); This = shdocvw_alloc(sizeof(*This));
This->vtbl = &dlVtbl; This->vtbl = &dlVtbl;
This->ref = 1; This->ref = 1;
This->hDialog = dlg; This->hDialog = dlg;

View File

@ -60,7 +60,7 @@ static void RegistryPropertyBag_Destroy(RegistryPropertyBag *This) {
TRACE("This=%p)\n", This); TRACE("This=%p)\n", This);
RegCloseKey(This->m_hInitPropertyBagKey); RegCloseKey(This->m_hInitPropertyBagKey);
HeapFree(GetProcessHeap(), 0, This); shdocvw_free(This);
} }
static HRESULT WINAPI RegistryPropertyBag_IPropertyBag_QueryInterface(IPropertyBag *iface, static HRESULT WINAPI RegistryPropertyBag_IPropertyBag_QueryInterface(IPropertyBag *iface,
@ -131,20 +131,20 @@ static HRESULT WINAPI RegistryPropertyBag_IPropertyBag_Read(IPropertyBag *iface,
if (res != ERROR_SUCCESS) if (res != ERROR_SUCCESS)
return E_INVALIDARG; return E_INVALIDARG;
pwszValue = HeapAlloc(GetProcessHeap(), 0, cbData); pwszValue = shdocvw_alloc(cbData);
if (!pwszValue) if (!pwszValue)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
res = RegQueryValueExW(This->m_hInitPropertyBagKey, pwszPropName, NULL, &dwType, res = RegQueryValueExW(This->m_hInitPropertyBagKey, pwszPropName, NULL, &dwType,
(LPBYTE)pwszValue, &cbData); (LPBYTE)pwszValue, &cbData);
if (res != ERROR_SUCCESS) { if (res != ERROR_SUCCESS) {
HeapFree(GetProcessHeap(), 0, pwszValue); shdocvw_free(pwszValue);
return E_INVALIDARG; return E_INVALIDARG;
} }
V_VT(pVar) = VT_BSTR; V_VT(pVar) = VT_BSTR;
V_BSTR(pVar) = SysAllocString(pwszValue); V_BSTR(pVar) = SysAllocString(pwszValue);
HeapFree(GetProcessHeap(), 0, pwszValue); shdocvw_free(pwszValue);
if (vtDst != VT_BSTR) { if (vtDst != VT_BSTR) {
hr = VariantChangeTypeEx(pVar, pVar, LOCALE_SYSTEM_DEFAULT, 0, vtDst); hr = VariantChangeTypeEx(pVar, pVar, LOCALE_SYSTEM_DEFAULT, 0, vtDst);
@ -177,7 +177,7 @@ HRESULT RegistryPropertyBag_Constructor(HKEY hInitPropertyBagKey, REFIID riid, L
TRACE("(hInitPropertyBagKey=%p, riid=%s, ppvObject=%p)\n", hInitPropertyBagKey, TRACE("(hInitPropertyBagKey=%p, riid=%s, ppvObject=%p)\n", hInitPropertyBagKey,
debugstr_guid(riid), ppvObject); debugstr_guid(riid), ppvObject);
pRegistryPropertyBag = HeapAlloc(GetProcessHeap(), 0, sizeof(RegistryPropertyBag)); pRegistryPropertyBag = shdocvw_alloc(sizeof(RegistryPropertyBag));
if (pRegistryPropertyBag) { if (pRegistryPropertyBag) {
pRegistryPropertyBag->lpIPropertyBagVtbl = &RegistryPropertyBag_IPropertyBagVtbl; pRegistryPropertyBag->lpIPropertyBagVtbl = &RegistryPropertyBag_IPropertyBagVtbl;
pRegistryPropertyBag->m_cRef = 0; pRegistryPropertyBag->m_cRef = 0;
@ -207,7 +207,7 @@ typedef struct _InstanceObjectFactory {
static void InstanceObjectFactory_Destroy(InstanceObjectFactory *This) { static void InstanceObjectFactory_Destroy(InstanceObjectFactory *This) {
IPropertyBag_Release(This->m_pPropertyBag); IPropertyBag_Release(This->m_pPropertyBag);
HeapFree(GetProcessHeap(), 0, This); shdocvw_free(This);
} }
static HRESULT WINAPI InstanceObjectFactory_IClassFactory_QueryInterface(IClassFactory *iface, static HRESULT WINAPI InstanceObjectFactory_IClassFactory_QueryInterface(IClassFactory *iface,
@ -323,7 +323,7 @@ HRESULT InstanceObjectFactory_Constructor(REFCLSID rclsid, IPropertyBag *pProper
TRACE("(RegistryPropertyBag=%p, riid=%s, ppvObject=%p)\n", pPropertyBag, TRACE("(RegistryPropertyBag=%p, riid=%s, ppvObject=%p)\n", pPropertyBag,
debugstr_guid(riid), ppvObject); debugstr_guid(riid), ppvObject);
pInstanceObjectFactory = HeapAlloc(GetProcessHeap(), 0, sizeof(InstanceObjectFactory)); pInstanceObjectFactory = shdocvw_alloc(sizeof(InstanceObjectFactory));
if (pInstanceObjectFactory) { if (pInstanceObjectFactory) {
pInstanceObjectFactory->lpIClassFactoryVtbl = &InstanceObjectFactory_IClassFactoryVtbl; pInstanceObjectFactory->lpIClassFactoryVtbl = &InstanceObjectFactory_IClassFactoryVtbl;
pInstanceObjectFactory->m_cRef = 0; pInstanceObjectFactory->m_cRef = 0;

View File

@ -133,7 +133,7 @@ static ULONG WINAPI WebBrowser_Release(IWebBrowser2 *iface)
WebBrowser_OleObject_Destroy(This); WebBrowser_OleObject_Destroy(This);
HeapFree(GetProcessHeap(), 0, This); shdocvw_free(This);
SHDOCVW_UnlockModule(); SHDOCVW_UnlockModule();
} }
@ -925,7 +925,7 @@ HRESULT WebBrowser_Create(IUnknown *pOuter, REFIID riid, void **ppv)
TRACE("(%p %s %p)\n", pOuter, debugstr_guid(riid), ppv); 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->lpWebBrowser2Vtbl = &WebBrowser2Vtbl;
ret->ref = 0; ret->ref = 0;
@ -949,7 +949,7 @@ HRESULT WebBrowser_Create(IUnknown *pOuter, REFIID riid, void **ppv)
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
SHDOCVW_LockModule(); SHDOCVW_LockModule();
}else { }else {
HeapFree(GetProcessHeap(), 0, ret); shdocvw_free(ret);
return hres; return hres;
} }