I am passing the address of pointer like char** from managed extension and
getting the
its initialized value from a C library dll.
How can i free the memory from the code in Managed Extension ?
Here is a sample C function i am calling from managed extension.
C dll Code
==============
extern "C" void __declspec(dllexport) Test(char **p)
{
int nSize = 10000;
*p= (char*)::malloc(nSize);
while(--nSize)
*(*p+nSize)='A';
}
// Iam currently calling back to C dll to free the memory it allocated.
extern "C" void __declspec(dllexport) TestFree(char **p)
{
::free(*p);
}
Managed Extension Code Function.
====================
StringBuilder *strB;
char *pszString;
Test(&pszString);
strB->Append(pszString);
//Marshal::FreeCoTaskMem((IntPtr)pszString); //This throws exception.after
certain number of iterations of calling this function
TestFree(&pszString); // I am currently calling this since above statement
does not work.
How can i free the memory in Managed Extension ?
Thanks!!!!