June 5th, 2011, 2:49 pm
QuoteOriginally posted by: CurtHagenlocherQuoteOriginally posted by: CuchulainnI suppose - like STL vectors - that this memory is all continguous?Yes. And in fact, if you're willing to use unsafe code, you can access it as a block by using Marshal.UnsafeAddrOfPinnedArrayElement to get the address of the first element and then performing indexing yourself. It's a C-style layout. I have no idea whether or not this is guaranteed to be stable in future versions of the CLR.I am getting the hang of Marshal. To test it, I do:1. AllocHGlobal to allocate unsafe global heap memory.2. Iterate over the array using Marshal.UnsafeAddrOfPinnedArrayElement and Marshal.ReadInt32()So far, so good. The remaining issues are how to process arrays of doubles (use char[]??) and making the code into a black box method with all the alloc/dealoc stuff in place.
Last edited by
Cuchulainn on June 4th, 2011, 10:00 pm, edited 1 time in total.