On page 85 of Don Box book, Essential COM, is a code like this:
STDMETHODIMP MyClass::UseIt(VARIANT var) {
VARIANT var2;
VariantInit(&var2);
VariantChangeType(&var2, &var, 0, VT_BSTR);
ustrcpy(m_szSomeDataMember, SAFEBSTR(V_BSTR(&var2)));
VariantClear(&var2);
}
I am wondering what happens if we do not call VariantClear? if VARIANT goes out of scope without calling this function, could it cause memory leak?
Thanks,
Ali
STDMETHODIMP MyClass::UseIt(VARIANT var) {
VARIANT var2;
VariantInit(&var2);
VariantChangeType(&var2, &var, 0, VT_BSTR);
ustrcpy(m_szSomeDataMember, SAFEBSTR(V_BSTR(&var2)));
VariantClear(&var2);
}
I am wondering what happens if we do not call VariantClear? if VARIANT goes out of scope without calling this function, could it cause memory leak?
Thanks,
Ali