<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Unsafe and reading from files</title><link>http://blogs.msdn.com/ericgu/archive/2004/04/13/112297.aspx</link><description>Einar wrote (long ago), In the article you wrote on unsafe image processing, you announced a follow-up that would "cover some more unsafe scenarios, including dealing with existing structures on disk". But then I guess something came up, and that article</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Novelty</title><link>http://blogs.msdn.com/ericgu/archive/2004/04/13/112297.aspx#112338</link><pubDate>Tue, 13 Apr 2004 19:09:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:112338</guid><dc:creator>JIS</dc:creator><description /></item><item><title>Novelty</title><link>http://blogs.msdn.com/ericgu/archive/2004/04/13/112297.aspx#112340</link><pubDate>Tue, 13 Apr 2004 19:10:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:112340</guid><dc:creator>JIS</dc:creator><description /></item><item><title>re: Unsafe and reading from files</title><link>http://blogs.msdn.com/ericgu/archive/2004/04/13/112297.aspx#112400</link><pubDate>Tue, 13 Apr 2004 17:13:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:112400</guid><dc:creator>Einar</dc:creator><description>What would be my second mistake, I wonder (not that I doubt having made one...)? &lt;br&gt;&lt;br&gt;Interestingly, I first read your article on unsafe code looking for ways to optimize code reading GPS data(!) Unfortunately, the GPS file was in ascii format, so I couldn't apply the technique you're showing here. Someone should take the time to produce an optimized yet flexible .NET library for reading GPS data from the serial port, a binary file, an ascii file etc. Perhaps someone already has?</description></item><item><title>re: Unsafe and reading from files</title><link>http://blogs.msdn.com/ericgu/archive/2004/04/13/112297.aspx#112451</link><pubDate>Tue, 13 Apr 2004 18:05:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:112451</guid><dc:creator>Einar</dc:creator><description>Oh, I forgot to say thanks for pulling my request out of bit oblivion and making a blog post of it! Thanks :)</description></item><item><title>re: Unsafe and reading from files</title><link>http://blogs.msdn.com/ericgu/archive/2004/04/13/112297.aspx#112980</link><pubDate>Wed, 14 Apr 2004 11:59:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:112980</guid><dc:creator>Einar</dc:creator><description>Oh, and I take it there's no equally simple solution for transforming an existing big-endian structure into a little-endian struct?</description></item><item><title>re: Unsafe and reading from files</title><link>http://blogs.msdn.com/ericgu/archive/2004/04/13/112297.aspx#116019</link><pubDate>Mon, 19 Apr 2004 16:25:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:116019</guid><dc:creator>Comments on alternative</dc:creator><description>I like the pointer manipulation you are using to cast the struct.  What are your thoughts on code like the following?&lt;br&gt;&lt;br&gt;public Boxcar(byte [] data)&lt;br&gt;{&lt;br&gt;	GCHandle hBoxCar = GCHandle.Alloc(data,&lt;br&gt; GCHandleType.Pinned);&lt;br&gt;&lt;br&gt;	IntPtr pBoxCar = hBoxCar.AddrOfPinnedObject();&lt;br&gt;&lt;br&gt;	Marshal.PtrToStructure(pBoxCar, this);&lt;br&gt;&lt;br&gt;	hBoxCar.Free();&lt;br&gt;}&lt;br&gt;&lt;br&gt;This uses the same struct layout attribute as in your example and it’s definitely not as simple as yours.&lt;br&gt;&lt;br&gt;Thanks&lt;br&gt;	-Mike	&lt;br&gt;</description></item></channel></rss>