Commit 1a6659e8 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

ole32: Remove unnecessary helpers to create/destroy bind context.

parent dd18a63b
......@@ -30,6 +30,7 @@
#include "objbase.h"
#include "wine/debug.h"
#include "wine/heap.h"
WINE_DEFAULT_DEBUG_CHANNEL(ole);
......@@ -112,41 +113,21 @@ static ULONG WINAPI BindCtxImpl_AddRef(IBindCtx* iface)
return InterlockedIncrement(&This->ref);
}
/******************************************************************************
* BindCtx_Destroy (local function)
*******************************************************************************/
static HRESULT BindCtxImpl_Destroy(BindCtxImpl* This)
{
TRACE("(%p)\n",This);
/* free the table space memory */
HeapFree(GetProcessHeap(),0,This->bindCtxTable);
/* free the bindctx structure */
HeapFree(GetProcessHeap(),0,This);
return S_OK;
}
/******************************************************************************
* BindCtx_Release
******************************************************************************/
static ULONG WINAPI BindCtxImpl_Release(IBindCtx* iface)
{
BindCtxImpl *This = impl_from_IBindCtx(iface);
ULONG ref;
BindCtxImpl *context = impl_from_IBindCtx(iface);
ULONG refcount = InterlockedDecrement(&context->ref);
TRACE("(%p)\n",This);
TRACE("%p refcount %d.\n", iface, refcount);
ref = InterlockedDecrement(&This->ref);
if (ref == 0)
if (!refcount)
{
/* release all registered objects */
BindCtxImpl_ReleaseBoundObjects(&This->IBindCtx_iface);
BindCtxImpl_Destroy(This);
BindCtxImpl_ReleaseBoundObjects(&context->IBindCtx_iface);
heap_free(context->bindCtxTable);
heap_free(context);
}
return ref;
return refcount;
}
......@@ -487,8 +468,6 @@ static HRESULT BindCtxImpl_ExpandTable(BindCtxImpl *This)
return S_OK;
}
/* Virtual function table for the BindCtx class. */
static const IBindCtxVtbl VT_BindCtxImpl =
{
BindCtxImpl_QueryInterface,
......@@ -507,73 +486,37 @@ static const IBindCtxVtbl VT_BindCtxImpl =
};
/******************************************************************************
* BindCtx_Construct (local function)
*******************************************************************************/
static HRESULT BindCtxImpl_Construct(BindCtxImpl* This)
{
TRACE("(%p)\n",This);
/* Initialize the virtual function table.*/
This->IBindCtx_iface.lpVtbl = &VT_BindCtxImpl;
This->ref = 0;
memset(&This->options, 0, sizeof(This->options));
This->options.cbStruct = sizeof(This->options);
This->options.grfMode = STGM_READWRITE;
This->options.dwClassContext = CLSCTX_SERVER;
This->options.locale = GetThreadLocale();
/* Initialize the bindctx table */
This->bindCtxTableSize=0;
This->bindCtxTableLastIndex=0;
This->bindCtxTable = NULL;
return S_OK;
}
/******************************************************************************
* CreateBindCtx (OLE32.@)
*
* Creates a bind context. A bind context encompasses information and options
* used when binding to a moniker.
*
* PARAMS
* reserved [I] Reserved. Set to 0.
* ppbc [O] Address that receives the bind context object.
*
* RETURNS
* Success: S_OK.
* Failure: Any HRESULT code.
*/
HRESULT WINAPI CreateBindCtx(DWORD reserved, LPBC * ppbc)
HRESULT WINAPI CreateBindCtx(DWORD reserved, IBindCtx **bind_context)
{
BindCtxImpl* newBindCtx;
HRESULT hr;
BindCtxImpl *object;
TRACE("(%d,%p)\n",reserved,ppbc);
TRACE("%#x, %p\n", reserved, bind_context);
if (!ppbc) return E_INVALIDARG;
if (!bind_context) return E_INVALIDARG;
*ppbc = NULL;
*bind_context = NULL;
if (reserved != 0)
if (reserved)
{
ERR("reserved should be 0, not 0x%x\n", reserved);
WARN("reserved should be 0, not 0x%x\n", reserved);
return E_INVALIDARG;
}
newBindCtx = HeapAlloc(GetProcessHeap(), 0, sizeof(BindCtxImpl));
if (newBindCtx == 0)
if (!(object = heap_alloc_zero(sizeof(*object))))
return E_OUTOFMEMORY;
hr = BindCtxImpl_Construct(newBindCtx);
if (FAILED(hr))
{
HeapFree(GetProcessHeap(),0,newBindCtx);
return hr;
}
object->IBindCtx_iface.lpVtbl = &VT_BindCtxImpl;
object->ref = 1;
object->options.cbStruct = sizeof(object->options);
object->options.grfMode = STGM_READWRITE;
object->options.dwClassContext = CLSCTX_SERVER;
object->options.locale = GetThreadLocale();
return BindCtxImpl_QueryInterface(&newBindCtx->IBindCtx_iface,&IID_IBindCtx,(void**)ppbc);
*bind_context = &object->IBindCtx_iface;
return S_OK;
}
/******************************************************************************
......
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