I presume Smart Pointers need to be specifically deleted when passed as a generic pointer type that gets assigned a value or a memory or resource leak will occur?
I'll use CComPtr as example. Will This Leak:
CComPtr<ISomeComObj> mycomobj;
SomeOtherComObject1->FunctionToFindComObject(&mycomobj);
SomeOtherComObject2->FunctionToFindComObject(&mycomobj);
If so, I presume the solution is to:
CComPtr<ISomeComObj> mycomobj;
SomeOtherComObject1->FunctionToFindComObject(&mycomobj);
mycomobj=NULL;
SomeOtherComObject2->FunctionToFindComObject(&mycomobj);
Or CString example:
void GetString(char **pstring)
{
*pstring=new char[123];
strncpy(*pstring, "Whatever", 122);
}
// this leaks, correct?
CString s;
GetString(&s);
GetString(&s);
// this is okay, correct?
CString c;
GetString(&c);
c=NULL;
GetString(&c);
?