My function that returns a string looks like this in c#:
[return: MarshalAs(UnmanagedType.LPWStr)]
public static string? GetText()
{
return SomeClass.SomeMethodThatReturnsAString();
}
And function that gets that string looks like this in cpp:
void OnWriteValue()
{
char16_t const *string = GetText();
if (string)
{
someMethodThatPrints(string);
freeMemoryThatIsAllocatedInCSharp(string);
}
}
And my question is how to implement "freeMemoryThatIsAllocatedInCSharp" considering that the code is used on windows and linux?
I thought GlobalFree is the solution here but there is no GlobalFree on linux.
stringback to a C# function that takes care of any cleanup it requires. So the functionfreeMemoryThatIsAllocatedInCSharp(string)would be implemented in C#.