[Mono-list] Can I call CoTaskMemAlloc on Linux?
Vincent Finn
vincent.finn at riverdocs.com
Thu Mar 15 14:24:03 EDT 2007
Robert Jordan wrote:
> Vincent Finn wrote:
>> Hi,
>>
>> I am sure this is a stupid question but I wanted to check before going
>> down the wrong route.
>>
>> On windows I am passing IntPtrs from C# to C++ and them using
>> SysAllocString on "UnmanagedType.LPWStr" and CoTaskMemAlloc on structs
>> when I want to return memory.
>>
>> In Visual Studio I need to include "oleauto.h" to get those functions,
>> and I then need to include "windows.h" to get various #defines used in
>> "oleauto.h".
>>
>> "windows.h" won't be on a Linux machine so can someone confirm for me
>> that CoTaskMemAlloc is portable and not MS?
>>
>> If it isn't what is the alternative?
>
> Instead of p/invoking you should use the following methods
> that do the right thing regardless of the platform:
>
> System.Runtime.InteropServices.Marshal.AllocCoTaskMem
>
> and
>
> System.Runtime.InteropServices.Marshal.FreeCoTaskMem
>
> Robert
This is the C++ side of things I am talking about, I can't call them
from my C++ code.
Vin
More information about the Mono-list
mailing list