For ex. i have c# COM object with such function:
int GetString([In, Out, MarshalAs(UnmanagedType.LPStr)]ref string str)
then i'm calling int from c++ (in c++ COM object is used via #import keyword), in generated wrapper method is declared as:
GetString(LPSTR * str, long * retVal)
i'm calling it this way:
char myStr[40];
LPSTR buf = (LPSTR)myStr;
LPSTR pBuf = &buf;
pComObject->GetString(pBuf);
what is strange:
1) myStr is not filled, and buf value is changed (it doesnt the same with myStr after the call) so, i suppose that c# marshaller allocates new block of memory
2) if c# allocates memory so should i call free(buf); or not?