I can't seem to find any specific information on pinning jagged arrays. For example:
void SomeMethod(array<array<Byte>^ >^ data) { // ... pin_ptr<Byte> pinnedPointer = &data[0][0]; //... } |
I can't seem to find any specific information on pinning jagged arrays. For example:
void SomeMethod(array<array<Byte>^ >^ data) { // ... pin_ptr<Byte> pinnedPointer = &data[0][0]; //... } |
pin_ptr and jagged arrays.
Music
I read in MSDN, it isn't really clear but this is what I understand it does.
The sub-object is the item in the array in the array, so the object that gets pinned is the array in the array. The array containing arrays is not pinned.
It would seem most logical.
Teo97917
Yes, that's kind of what I was assuming too.
The problem with that is that, since pin_ptr must be allocated on the stack and cannot be an element of an unmanaged array, you can't use pin_ptr to pin a dynamic number of managed objects (arrays in this case).
For example, if I have a jagged array (an array of arrays) and all array elements need to be used by unmanaged code, I have no way of using pin_ptr to pin that arbitrary number of elements. I would have to know at compile-time how many elements are in the array and declare that number of pin_ptr variables to deal with it.
Maggie Yin
MikeCai