Macros

The following macros are used to perform repetitive tasks.

Macro Description
IS_SAME_GUIDS(riid1, riid2) Use to test whether two UUIDs are the same. Evaluates to TRUE if the given UUIDs are the same, FALSE if not.
RETURN_ON_FAILURE(hr) Use to test a return value within a function that returns HRESULT. If hr is a failure code, then the function returns the failure code to the caller. Otherwise, execution continues to the next statement.
RETURN_ON_NULLALLOC(ptr) Use to test whether a pointer is NULL within a function that returns HRESULT. If the pointer is NULL, then the function returns E_OUTOFMEMORY to the caller. Otherwise, execution continues to the next statement.
RELEASE_OBJECT(ptr) Use to release a COM object pointer. If the pointer is not NULL, then its IUnknown::Release method is called and the pointer is set to NULL.
QUICK_RELEASE(ptr) Similar to RELEASE_OBJECT, except that the pointer is not set to NULL.
ADDREF_OBJECT(ptr) Use to add a reference to a COM object pointer. If the pointer is not NULL, then its IUnknown::AddRef method is called.
CHECK_POINTER(val) Use within a function that returns an HRESULT to check whether a pointer is not NULL and can be written up to four bytes. If the pointer is NULL or cannot be written up to four bytes, then E_POINTER is returned.
CHECK_POINTER_SIZE(val, sz) Similar to CHECK_POINTER, except the user must specify the size to check whether the pointer can be written to.