Trying to get value from unmanaged memory

Hello everyone.

I'm working on my Unity project with teamspeak and I have to retrieve some id. I have to transfert my id from a unmanaged memory to managed one (with Marshalling) .

So I have this snipset of code :


            anyID **list = NULL;
            list = (anyID**)malloc(sizeof(anyID));

            error = Ts3client.ts3client_getClientList(scHandlerID,ref list);
            if(error != public_errors.ERROR_ok)
                Debug.Log("error client list");

            string test = Marshal.PtrToStringAnsi(list);

with :


unsigned intts3client_getClientList(serverConnectionHandlerID, result);
uint64 serverConnectionHandlerID;
anyID** result;

I have compiler error that's saying : * Pointers and fixed size buffers may only be used in an unsafe context*

Do you have an idea how can I fix this ? Thanks a lot guys

1 Answer

1

Yeah, Unity3D allows only safe code. Pointers are considered unsafe code.

Oh :( And do you have an idea how can I manage that ?

Write a wrapper with interop http://msdn.microsoft.com/en-us/library/e59b22c5(v=VS.90).aspx