private static Asarerror[] cleanerrors(Rawasarerror *ptr, int length) { Asarerror[] output = new Asarerror[length]; // Better create a new array // to avoid pointer erros, corruption and may other problems. for (int i = 0; i < length; i++) { output[i].Fullerrdata = Marshal.PtrToStringAnsi(ptr[i].fullerrdata); output[i].Rawerrdata = Marshal.PtrToStringAnsi(ptr[i].rawerrdata); output[i].Block = Marshal.PtrToStringAnsi(ptr[i].block); output[i].Filename = Marshal.PtrToStringAnsi(ptr[i].filename); output[i].Line = ptr[i].line; output[i].Callerfilename = Marshal.PtrToStringAnsi(ptr[i].callerfilename); output[i].Callerline = ptr[i].callerline; } return(output); }
private static Asarerror[] cleanerrors(RawAsarError *ptr, int length) { Asarerror[] output = new Asarerror[length]; // Copy unmanaged to managed memory to avoid potential errors in case the area // gets cleared by Asar. for (int i = 0; i < length; i++) { output[i].Fullerrdata = Marshal.PtrToStringAnsi(ptr[i].fullerrdata); output[i].Rawerrdata = Marshal.PtrToStringAnsi(ptr[i].rawerrdata); output[i].Block = Marshal.PtrToStringAnsi(ptr[i].block); output[i].Filename = Marshal.PtrToStringAnsi(ptr[i].filename); output[i].Line = ptr[i].line; output[i].Callerfilename = Marshal.PtrToStringAnsi(ptr[i].callerfilename); output[i].Callerline = ptr[i].callerline; output[i].ErrorId = ptr[i].errid; } return(output); }