Bugzilla – Bug 314241
[PATCH] Marshal.UnsafeAddrOfPinnedArrayElement patches
Last modified: 2007-09-15 21:24:06 UTC
---- Reported by vladimir@pobox.com 2004-03-30 02:26:01 MST ---- Attached are two small patches that implement System.Runtime.InteropServices.Marshal.UnsafeAddrOfPinnedArrayElement(). My simple tests seem to work right, but I could be doing something horribly wrong. ---- Additional Comments From vladimir@pobox.com 2004-03-30 02:26:21 MST ---- Created an attachment (id=165818) mcs_arrayaddr.patch ---- Additional Comments From vladimir@pobox.com 2004-03-30 02:26:44 MST ---- Created an attachment (id=165819) mono_arrayaddr.patch ---- Additional Comments From bmaurer@users.sf.net 2004-04-04 11:20:12 MST ---- It would be pretty easy to make an opcode in this for mini so that it was fast (look at ldelema, but just do it without the bounds check. also,you will have to access the vtable->klass to find out the element size). MSDN says: `For maximum performance, this method does no validation on the array passed to it; this can result in unexpected behavior.', so it sounds like they think it is a method that needs to be performant. not really a big issue though. ---- Additional Comments From bmaurer@users.sf.net 2004-04-04 11:43:46 MST ---- also, look at: #define mono_array_addr_with_size(array,size,index) ( ((char*)(array)->vector) + (size) * (index) ) you should probably use that for the icall version, for neatness. ---- Additional Comments From vargaz@freemail.hu 2004-05-05 08:02:50 MST ---- Fixed in CVS. Thanks for the patch. Imported an attachment (id=165818) Imported an attachment (id=165819)