Exemple #1
0
        public static IntPtr Pin <T> (this T[] obj, PinnedObjects ctx)
        {
            GCHandle hnd = GCHandle.Alloc(obj, GCHandleType.Pinned);

            ctx.Handles.Add(hnd);
            return(hnd.AddrOfPinnedObject());
        }
Exemple #2
0
        public static IntPtr Pin(this string obj, PinnedObjects ctx)
        {
            byte[]   n   = System.Text.Encoding.UTF8.GetBytes(obj + '\0');
            GCHandle hnd = GCHandle.Alloc(n, GCHandleType.Pinned);

            ctx.Handles.Add(hnd);
            return(hnd.AddrOfPinnedObject());
        }