I'm quite new to C# and I'm having trouble releasing unmanaged resource. For the function CharPtrToString, is it necessary to release IntPtr? In addition, would it be safe to call List < MyStruct >.clear() without causing a memory leak?
public string CharPtrToString(MycharArray chararray)
{
IntPtr ipp = (IntPtr)chararray;
string s = Marshal.PtrToStringAnsi(ipp)
//need to free Ipp?
return s;
}
public struct MyStruct
{
public Int int1;
public MyCharArray charArray;
}
public unsafe struct MyCharArray
{
public char* charPointer;
}