Fix memory leaks

This commit is contained in:
筱傑 2019-08-21 09:23:32 +08:00 committed by GitHub
parent ba24c4ea0f
commit fca1955f1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -314,10 +314,12 @@ namespace USBCAN
for (int i = 0; i < len; i++)
{
// 实例化帧对象,装入帧缓冲区
_FrameBuffer.Add((CAN_API.VCI_CAN_OBJ)Marshal.PtrToStructure((IntPtr)((uint)readBuffer + i * Marshal.SizeOf(typeof(CAN_API.VCI_CAN_OBJ))), typeof(CAN_API.VCI_CAN_OBJ)));
//_FrameBuffer.Add((CAN_API.VCI_CAN_OBJ)Marshal.PtrToStructure((IntPtr)((uint)readBuffer + i * Marshal.SizeOf(typeof(CAN_API.VCI_CAN_OBJ))), typeof(CAN_API.VCI_CAN_OBJ)));
_FrameBuffer.Add(Marshal.PtrToStructure<CAN_API.VCI_CAN_OBJ>((IntPtr)((uint)readBuffer + i * Marshal.SizeOf(typeof(CAN_API.VCI_CAN_OBJ)))));
}
}
}
Marshal.FreeHGlobal(readBuffer);
}
/// <summary>