__pin Return 0

R

rob

I have the following code:

int Function(short buffer __gc[]) {
....
short __pin* inPinned = & buffer[0];
DoSomethingUnsafe(inPinned)
...
}

&buffer[0] shows a valid address but when I pin it down inPinned is 0.
Why does this not work?

Thanks
 
M

Marcus Heege

Hi Rob
rob said:
I have the following code:

int Function(short buffer __gc[]) {
....
short __pin* inPinned = & buffer[0];
DoSomethingUnsafe(inPinned)
...
}

&buffer[0] shows a valid address but when I pin it down inPinned is 0.
Why does this not work?

Thanks

Your observation is wrong. The code below dumps a valid address:

#using <mscorlib.dll>
#include <stdio.h>

#pragma unmanaged
void DoSomethingUnsafe(short* p)
{
printf("p = 0x%X", p);
}
#pragma managed

int main()
{
short buffer __gc[] = {1, 2, 3};
short __pin* inPinned = & buffer[0];
DoSomethingUnsafe(inPinned);
}

Marcus
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top