
Question about SAFEARRAYS and deleteing them
I'm reading a COM+/ATL book (Andrew Troelsen-- very good), and in the
section on SAFEARRAYS he has some code like so:
STDMETHOD CCoSafeArray::UseThisSafeArrayOfStrings(VARIANT strings)
{
.
.
.
SAFEARRAY *pSA = strings.parray;
.
.
.
.
SafeArrayUnaccessData(pSA);
SafeArrayDestroy(pSA); //what the...?
Quote:
}
My question is: why am I destroying the SAFEARRAY? Up at the top of the
function, I didn't allocate any memory for it-- I'm just pointing to the
incoming parameter's copy of the array. Maybe I'm mistaken, and assigning a
SAFEARRAY pointer to another array somehow allocates memory in the
background? Or do you think this is a typo on the author's part? Thanks
for the clarification.