예제 #1
0
        public unsafe int NativeArrayOut(out int[] arr, int len)
        {
            var data = stackalloc int[3];

            if (len <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(len));
            }

            var arrBuf = NativeUtils.ArrayToIntSpan(null, len);

            fixed(int *pinned = arrBuf)
            {
                data[0] = NativeUtils.IntPointerToInt(pinned);
                data[1] = NativeUtils.IntPointerToInt(data + 2);
                data[2] = len;


                var result = Interop.FastNativeInvoke(new IntPtr(9999), "A[*1]d", data);

                arr = NativeUtils.IntSpanToArray <int>(null, arrBuf);

                return(result);
            }
        }
예제 #2
0
        public Span <int> CastArray(int[] a)
        {
            var spn = NativeUtils.ArrayToIntSpan(a, a.Length);

            return(spn);
        }