C
Christopher
void Foo(IUnknown ** ppMicrosoftsOut)
{
// If the operation fails param is NULL
// Otherwise param is a valid pointer to object
}
I can't change the function prototype, because there is already a lot
of code that depends on it. How do I initialize the parameter properly
in the function body, such that all of the following calls from the
client yield the expected results?
1) Foo(NULL);
2) IUnknown * result = somePointerToAlreadyInstantiatedObject;
Foo(&result);
3) IUnknown * result = NULL;
Foo(&result);
This is my attempt:
if( ppRS && *ppRS )
{
(*ppRS)->Release();
(*ppRS) = NULL;
}
// Do stuff
// If failed
return;
// If successfull
*ppRS = pointerToInterface;
Is that correct?
{
// If the operation fails param is NULL
// Otherwise param is a valid pointer to object
}
I can't change the function prototype, because there is already a lot
of code that depends on it. How do I initialize the parameter properly
in the function body, such that all of the following calls from the
client yield the expected results?
1) Foo(NULL);
2) IUnknown * result = somePointerToAlreadyInstantiatedObject;
Foo(&result);
3) IUnknown * result = NULL;
Foo(&result);
This is my attempt:
if( ppRS && *ppRS )
{
(*ppRS)->Release();
(*ppRS) = NULL;
}
// Do stuff
// If failed
return;
// If successfull
*ppRS = pointerToInterface;
Is that correct?