How to free member (i.e BSTR, SAFEARRAY, VARIANT) of an IDL User Defined Structure which is encapsul
Posted
by Picaro De Vosio
on Stack Overflow
See other posts from Stack Overflow
or by Picaro De Vosio
Published on 2010-04-18T12:22:18Z
Indexed on
2010/04/18
12:23 UTC
Read the original article
Hit count: 369
Hi,
I have a structure defined in IDL. This structure has following members:
{
BSTR m_sFirst;
BSTR m_sSecond;
VARIANT m_vChildStruct; //This member encapsulate a sub structure
SAFEARRAY __RPC_FAR * m_saArray;
}CustomINFO;
I am allocating the memory for the structs using CoTaskMemAlloc and encapsulating it in Variant as follows:
vV->vt = VT_RECORD;
vV->pvRecord = pStruct; //Pointer of sturct
vV->pRecInfo = pRI; //RecordInfo Interface
Is it enough to call VariantClear to deallocate the memory of struct and its members? Will it also release the IRecordInfo interface?
Or i have to manually get the encapsulated struct and deallocate each member myself and then use CoTaskMemFree to deallocate sturct.
Thanks
Picaro De Vosio
© Stack Overflow or respective owner