20#include <winpr/config.h>
22#include <winpr/assert.h>
23#include <winpr/interlocked.h>
24#include <winpr/wlog.h>
28#define TAG WINPR_TAG("utils.com")
37 object->lpVtbl = vtbl;
39 object->className = className ? className :
"wComBase";
46 const LONG count = InterlockedIncrement(&object->refCount);
47 WLog_VRB(TAG,
"%s::AddRef() -> %" PRId32, object->className, (INT32)count);
54 const LONG count = InterlockedDecrement(&object->refCount);
55 WLog_VRB(TAG,
"%s::Release() -> %" PRId32, object->className, (INT32)count);
59 WLog_ERR(TAG,
"%s: released more often than referenced", object->className);
77 object->className, WINPR_COM_GUID_ARGS(riid));
#define WINPR_COM_GUID_FMT
printf a GUID as {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}: WLog_DBG(TAG, "id=" WINPR_COM_GUID_FMT,...
void(* pfnwComBaseFree)(wComBase *object)
called when the last reference goes away: releases what the object holds and frees it
static BOOL winpr_com_guid_equal(const GUID *a, const GUID *b)
IsEqualGUID.
WINPR_API void winpr_com_base_init(wComBase *object, const char *className, const wIUnknownVtbl *vtbl, pfnwComBaseFree Free)
sets the vtable and the reference count to 1, the caller owns that first reference.
WINPR_API ULONG winpr_com_base_add_ref(wComBase *object)
AddRef of an object starting with a wComBase.
WINPR_API HRESULT winpr_com_base_query(wComBase *object, const IID *iid, const IID *riid, void **ppv)
QueryInterface of an object whose only interface is iid (nullptr: IUnknown only). On success *ppv is ...
WINPR_API ULONG winpr_com_base_release(wComBase *object)
Release of an object starting with a wComBase: calls its Free at 0.
the vtable of IUnknown, the first entries of every COM vtable