<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8093909139580325869</id><updated>2011-11-05T05:56:04.136-07:00</updated><title type='text'>Yet Another Mac Dev Blog</title><subtitle type='html'>asr -source /childlike/wonder -target /world -noverify -noprompt</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://yamacdev.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://yamacdev.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Blake C.</name><uri>http://www.blogger.com/profile/08296013471634395562</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>44</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8093909139580325869.post-3914960679801023313</id><published>2008-10-14T21:11:00.000-07:00</published><updated>2009-06-04T22:58:23.483-07:00</updated><title type='text'>Valgrind</title><content type='html'>Many of us have wanted &lt;a href="http://valgrind.org/"&gt;Valgrind&lt;/a&gt; on OS X for a long time, and now &lt;a href="http://www.sealiesoftware.com/valgrind/index.html"&gt;we finally have it&lt;/a&gt;, thanks to Greg Parker. Valgrind provides some impressive &lt;a href="http://en.wikipedia.org/wiki/Dynamic_program_analysis"&gt;dynamic analysis&lt;/a&gt; that complements the &lt;a href="http://en.wikipedia.org/wiki/Static_code_analysis"&gt;static analysis&lt;/a&gt; we can get from &lt;a href="http://clang.llvm.org/StaticAnalysis.html"&gt;clang's checker&lt;/a&gt;. This &lt;a href="http://dot.kde.org/2006/02/20/interview-valgrind-author-julian-seward"&gt;interview with the original author&lt;/a&gt; has a good description of what it does and how it works.&lt;br /&gt;&lt;br /&gt;I've used Valgrind a bit, and it has earned its place in my toolbox. Here are some things I've learned.&lt;br /&gt;&lt;br /&gt;While the LLVM checker analyzes your source files and tries to check every possible code path, Valgrind analyzes your &lt;i&gt;built executable&lt;/i&gt; and only checks the code path that you specify. LLVM's checker uses lexical analysis and hypothetical variable values to point out problems. Valgrind, on the other hand, translates your executable's machine code into an instrumented bytecode representation, and runs that code in a virtual machine. There are no hypothetical values, so the accuracy of the results is much higher, but the coverage is drastically reduced.&lt;br /&gt;&lt;br /&gt;Valgrind instruments ALL of the code that your executable executes, including libraries/frameworks/bundles that were linked against or dynamically loaded. This is possible because Valgrind's input is the machine code that you execute, not the source code that you compile. This provides tremendous opportunities for us to help improve the quality of the binaries we use, but do not own.&lt;br /&gt;&lt;br /&gt;With the previous two paragraphs in mind, it is important to note that the actual code path taken by an executable can differ from launch to launch, even when launched repeatedly with the same arguments. Maybe a system cache gets updated, or one of your linked frameworks decides to contact an update server, etc. When your code exercises different paths, different code paths get checked.&lt;br /&gt;&lt;br /&gt;Valgrind has a firm grip on your RAM. If you overflow or underflow a buffer on the heap, you'll hear about it. If you read from or write to freed memory, you'll hear about it. If you allocate with new and deallocate with delete[], you'll hear about it.&lt;br /&gt;&lt;br /&gt;Valgrind can catch some errors that clang's checker cannot, and vice versa. And there are other errors that both tools will catch. By using these two tools on all of our projects, we can improve our code as well as other people's code that we use at runtime.&lt;br /&gt;&lt;br /&gt;Hat's off to the devs who've worked on Valgrind and LLVM's checker. I wish we had these tools a long time ago.&lt;br /&gt;&lt;br /&gt;Update: &lt;a href="http://blog.mozilla.com/nnethercote/2009/05/28/mac-os-x-now-supported-on-the-valgrind-trunk/"&gt;Branch merged to trunk&lt;/a&gt;. Thanks to Dan for the heads-up in comments.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8093909139580325869-3914960679801023313?l=yamacdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamacdev.blogspot.com/feeds/3914960679801023313/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8093909139580325869&amp;postID=3914960679801023313' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/3914960679801023313'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/3914960679801023313'/><link rel='alternate' type='text/html' href='http://yamacdev.blogspot.com/2008/10/valgrind.html' title='Valgrind'/><author><name>Blake C.</name><uri>http://www.blogger.com/profile/08296013471634395562</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8093909139580325869.post-1853532015483018370</id><published>2008-09-08T21:47:00.000-07:00</published><updated>2008-09-08T22:06:06.208-07:00</updated><title type='text'>Fun With Digraphs</title><content type='html'>Christ, I can't believe this compiles-&lt;br /&gt;&lt;pre class=".source_code"&gt;%:include &amp;#60;stdio.h&amp;#62;&lt;br /&gt;%:include &amp;#60;Cocoa/Cocoa.h&amp;#62;&lt;br /&gt;&lt;br /&gt;int main()&lt;br /&gt;&amp;#60;%&lt;br /&gt;    NSString *message = @"Hello, world";&lt;br /&gt;&lt;br /&gt;    printf("%s\n", &amp;#60;:message UTF8String:&amp;#62;);&lt;br /&gt;&lt;br /&gt;    return 0;&lt;br /&gt;%&amp;#62;&lt;/pre&gt;&lt;br /&gt;It's section 6.4.6 in &lt;a href="http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf"&gt;the C spec&lt;/a&gt;. Good stuff for playing jokes on coworkers, but please don't ship code like this.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8093909139580325869-1853532015483018370?l=yamacdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamacdev.blogspot.com/feeds/1853532015483018370/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8093909139580325869&amp;postID=1853532015483018370' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/1853532015483018370'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/1853532015483018370'/><link rel='alternate' type='text/html' href='http://yamacdev.blogspot.com/2008/09/fun-with-digraphs.html' title='Fun With Digraphs'/><author><name>Blake C.</name><uri>http://www.blogger.com/profile/08296013471634395562</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8093909139580325869.post-6702960144067568956</id><published>2008-08-26T21:23:00.000-07:00</published><updated>2008-08-26T21:24:48.561-07:00</updated><title type='text'>Tapuless</title><content type='html'>&lt;a href="http://www.techcrunch.com/2008/08/26/tapulous-cofounder-mike-lee-ejected-from-company/"&gt;Jobs come and go&lt;/a&gt;, as do the companies that provide them.&lt;br /&gt;&lt;br /&gt;Friends stick around, and solid engineering outlives the engineer.&lt;br /&gt;&lt;br /&gt;I'll give you one guess who I'm betting on.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8093909139580325869-6702960144067568956?l=yamacdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamacdev.blogspot.com/feeds/6702960144067568956/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8093909139580325869&amp;postID=6702960144067568956' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/6702960144067568956'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/6702960144067568956'/><link rel='alternate' type='text/html' href='http://yamacdev.blogspot.com/2008/08/tapuless.html' title='Tapuless'/><author><name>Blake C.</name><uri>http://www.blogger.com/profile/08296013471634395562</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8093909139580325869.post-6030073211672602422</id><published>2008-06-15T11:05:00.000-07:00</published><updated>2008-06-15T11:14:40.830-07:00</updated><title type='text'>For the Record</title><content type='html'>Brent Simmons DID NOT get arrested- he paid for that case of Bud.&lt;br /&gt;&lt;br /&gt;The World's Toughest Programmer and I DID steal a few Buds from Brent. We also WERE NOT arrested.&lt;br /&gt;&lt;br /&gt;There did seem to be MORE red lemur shirts than Apple Engineer shirts.&lt;br /&gt;&lt;br /&gt;Kevin Ballard DID shave his beard on a dare.&lt;br /&gt;&lt;br /&gt;I DID lose every game of pool I played last week.&lt;br /&gt;&lt;br /&gt;She was not a "14-year-old" friend- she was an old friend I hadn't seen since we were 14.&lt;br /&gt;&lt;br /&gt;Add your own records in comments if desired.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8093909139580325869-6030073211672602422?l=yamacdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamacdev.blogspot.com/feeds/6030073211672602422/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8093909139580325869&amp;postID=6030073211672602422' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/6030073211672602422'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/6030073211672602422'/><link rel='alternate' type='text/html' href='http://yamacdev.blogspot.com/2008/06/for-record.html' title='For the Record'/><author><name>Blake C.</name><uri>http://www.blogger.com/profile/08296013471634395562</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8093909139580325869.post-3012731031113762785</id><published>2008-06-09T00:12:00.000-07:00</published><updated>2008-06-09T00:13:52.991-07:00</updated><title type='text'>Where In SF Is Blake?</title><content type='html'>Find me if you can :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8093909139580325869-3012731031113762785?l=yamacdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamacdev.blogspot.com/feeds/3012731031113762785/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8093909139580325869&amp;postID=3012731031113762785' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/3012731031113762785'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/3012731031113762785'/><link rel='alternate' type='text/html' href='http://yamacdev.blogspot.com/2008/06/where-in-sf-is-blake.html' title='Where In SF Is Blake?'/><author><name>Blake C.</name><uri>http://www.blogger.com/profile/08296013471634395562</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8093909139580325869.post-3328709955055063666</id><published>2008-04-01T18:33:00.000-07:00</published><updated>2008-04-01T18:37:48.289-07:00</updated><title type='text'>Resistance Is Futile</title><content type='html'>I'm pleased to announce that I've accepted a job offer from Microsoft. I can't wait to shuffle off the coil of Objective-C and revel in the awesomeness that is C# and .NET.&lt;br /&gt;&lt;br /&gt;Also, you Mac developers were getting a little smug for my taste. See ya, suckers!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8093909139580325869-3328709955055063666?l=yamacdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamacdev.blogspot.com/feeds/3328709955055063666/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8093909139580325869&amp;postID=3328709955055063666' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/3328709955055063666'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/3328709955055063666'/><link rel='alternate' type='text/html' href='http://yamacdev.blogspot.com/2008/04/resistance-is-futile.html' title='Resistance Is Futile'/><author><name>Blake C.</name><uri>http://www.blogger.com/profile/08296013471634395562</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8093909139580325869.post-1703798083929935598</id><published>2008-01-24T17:50:00.000-08:00</published><updated>2008-01-24T17:53:16.450-08:00</updated><title type='text'>24 Days</title><content type='html'>I was &lt;a href="http://yamacdev.blogspot.com/2007/01/year-of-hig.html"&gt;a little bit off&lt;/a&gt;, but &lt;a href="http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/XHIGIntro/chapter_1_section_1.html"&gt;here it is&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8093909139580325869-1703798083929935598?l=yamacdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamacdev.blogspot.com/feeds/1703798083929935598/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8093909139580325869&amp;postID=1703798083929935598' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/1703798083929935598'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/1703798083929935598'/><link rel='alternate' type='text/html' href='http://yamacdev.blogspot.com/2008/01/24-days.html' title='24 Days'/><author><name>Blake C.</name><uri>http://www.blogger.com/profile/08296013471634395562</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8093909139580325869.post-7214430789040859855</id><published>2008-01-10T14:30:00.000-08:00</published><updated>2008-01-15T15:29:53.772-08:00</updated><title type='text'>I Did Not Know That</title><content type='html'>Xcode's Cocoa project templates have 2 occurrences of "#import &amp;#60Cocoa/Cocoa.h&amp;#62"- One in the prefix file and one in main.m. The behavior of #import means that only the first occurrence actually matters, but then why would I need the second one in main.m? It turns out that in a monochrome world, I don't. But if you're like me and you use syntax coloring at all, deleting the unnecessary #import in main.m(and any other source files) will leave you with not-so-pretty coloring of all the Cocoa bits.&lt;br /&gt;&lt;br /&gt;I'm guilty of deleting the unnecessary #import on general principle, and I'm guessing somebody else out there has done this as well.&lt;br /&gt;&lt;br /&gt;Update: I'm now unable to reproduce the syntax coloring problem by deleting the unnecessary #import. However, the problem did exist for myself and others, and was fixed by adding the #import back to a source file. I guess the advice here is: If you have coloring issues and the #import is missing, add it back.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8093909139580325869-7214430789040859855?l=yamacdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamacdev.blogspot.com/feeds/7214430789040859855/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8093909139580325869&amp;postID=7214430789040859855' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/7214430789040859855'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/7214430789040859855'/><link rel='alternate' type='text/html' href='http://yamacdev.blogspot.com/2008/01/i-did-not-know-that.html' title='I Did Not Know That'/><author><name>Blake C.</name><uri>http://www.blogger.com/profile/08296013471634395562</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8093909139580325869.post-7734033450846602510</id><published>2007-11-05T18:42:00.000-08:00</published><updated>2007-11-09T14:19:04.524-08:00</updated><title type='text'>The Leopard Ate My Code</title><content type='html'>or: How I Learned to Stop Worrying and Love the Leopard&lt;br /&gt;&lt;br /&gt;Since Tiger appeared, many people have been jumping through some interesting hoops to get the iTunes-style "inset" text appearance in metal windows. Some people draw the text twice, where the first drawing is a lighter color and offset down by one pixel. Others are now apparently resorting to image editing products to get a similar result. I've mentioned &lt;a href="http://www.latenightsw.com/blog/?p=45"&gt;elsewhere&lt;/a&gt; that drawing the text twice is not necessary, and now it gets even easier with Leopard.&lt;br /&gt;&lt;br /&gt;Update: Ken points out in a comment that drawing the text twice can have better results than using NSShadow on Tiger. It's still much easier on Leopard.&lt;br /&gt;&lt;br /&gt;Here's a simple way to do it on Tiger, using attributed strings and NSShadow:&lt;br /&gt;&lt;br /&gt;&lt;pre class=".source_code"&gt;NSTextField* textField = something from IB;&lt;br /&gt;NSShadow* textShadow = [[NSShadow alloc] init];&lt;br /&gt;&lt;br /&gt;[textShadow setShadowColor: [NSColor&lt;br /&gt;    colorWithCalibratedRed: 1.0 green: 1.0 blue: 1.0 alpha: 0.5]];&lt;br /&gt;[textShadow setShadowOffset: NSMakeSize(0.0, -1.0)];&lt;br /&gt;[textShadow setShadowBlurRadius: 0.0];&lt;br /&gt;&lt;br /&gt;NSMutableAttributedString* newString =&lt;br /&gt;    [[NSMutableAttributedString alloc] initWithAttributedString:&lt;br /&gt;    [textField attributedStringValue]];&lt;br /&gt;&lt;br /&gt;[newString addAttribute: NSShadowAttributeName value: textShadow&lt;br /&gt;    range: NSMakeRange(0, [newString length])];&lt;br /&gt;[textField setAttributedStringValue: newString];&lt;br /&gt;[newString release];&lt;/pre&gt;&lt;br /&gt;Not too bad, although the color values, pixel offset, etc. are hardcoded. Now let's see how much code it takes to achieve a similar result in Leopard:&lt;br /&gt;&lt;br /&gt;&lt;pre class=".source_code"&gt;[[textField cell] setBackgroundStyle: NSBackgroundStyleRaised];&lt;/pre&gt;&lt;br /&gt;Nice.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8093909139580325869-7734033450846602510?l=yamacdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamacdev.blogspot.com/feeds/7734033450846602510/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8093909139580325869&amp;postID=7734033450846602510' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/7734033450846602510'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/7734033450846602510'/><link rel='alternate' type='text/html' href='http://yamacdev.blogspot.com/2007/11/leopard-ate-my-code.html' title='The Leopard Ate My Code'/><author><name>Blake C.</name><uri>http://www.blogger.com/profile/08296013471634395562</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8093909139580325869.post-2904233699799651843</id><published>2007-09-05T20:55:00.000-07:00</published><updated>2007-09-06T15:07:32.417-07:00</updated><title type='text'>Speaking of Backtraces</title><content type='html'>&lt;a href="http://bugzilla.gnome.org/show_bug.cgi?id=47237%30"&gt;Words escape me.&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8093909139580325869-2904233699799651843?l=yamacdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamacdev.blogspot.com/feeds/2904233699799651843/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8093909139580325869&amp;postID=2904233699799651843' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/2904233699799651843'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/2904233699799651843'/><link rel='alternate' type='text/html' href='http://yamacdev.blogspot.com/2007/09/speaking-of-backtraces.html' title='Speaking of Backtraces'/><author><name>Blake C.</name><uri>http://www.blogger.com/profile/08296013471634395562</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8093909139580325869.post-4040614658290992626</id><published>2007-09-04T21:10:00.000-07:00</published><updated>2008-01-16T12:25:25.677-08:00</updated><title type='text'>The Case of the Missing Stack Frames</title><content type='html'>Our friend &lt;a href="http://boredzo.org/blog/"&gt;Peter Hosey&lt;/a&gt; recently &lt;a href="http://boredzo.org/blog/archives/2007-08-14/fixing-an-adium-bug-a-timeline"&gt;mentioned&lt;/a&gt; a problem that frequently makes debugging crash reports harder than usual. The problem is that stack traces don't always display every stack frame in the call chain, which can make it difficult or impossible to determine the flow of control that led to the crash. Let's look at a demonstration of the problem, its causes, and its solutions.&lt;br /&gt;&lt;br /&gt;Update: I probably should have mentioned this before- optimizations make debugging hard. Debug builds should not use any optimizations at all, unless you enjoy headaches. With no optimizations in place, your debug builds will not suffer from missing stack frames. This post is intended to help developers who have received crash reports from users testing release builds, where optimizations have been made.&lt;br /&gt;&lt;br /&gt;Note: I'll be using only the x86 assembly in this post. If anyone is interested, let me know and I'll post the ppc equivalents in a followup post.&lt;br /&gt;&lt;br /&gt;A sample app:&lt;br /&gt;&lt;br /&gt;&lt;pre class=".source_code"&gt;int func2(int x)&lt;br /&gt;{&lt;br /&gt;    return x - 1;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int func1(int x)&lt;br /&gt;{&lt;br /&gt;    int result = func2(x);&lt;br /&gt;    return result;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int main(int argc, const char** argv)&lt;br /&gt;{&lt;br /&gt;    return func1(1);&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Here's what that looks like when compiled with no optimizations(-O0):&lt;br /&gt;&lt;br /&gt;&lt;pre class=".source_code"&gt;_func2:&lt;br /&gt;    +0  00001f7e  55                      pushl       %ebp&lt;br /&gt;    +1  00001f7f  89e5                    movl        %esp,%ebp&lt;br /&gt;    +3  00001f81  83ec08                  subl        $0x08,%esp&lt;br /&gt;    +6  00001f84  8b4508                  movl        0x08(%ebp),%eax&lt;br /&gt;    +9  00001f87  83e801                  subl        $0x01,%eax&lt;br /&gt;   +12  00001f8a  c9                      leave&lt;br /&gt;   +13  00001f8b  c3                      ret&lt;br /&gt;&lt;br /&gt;_func1:&lt;br /&gt;    +0  00001f8c  55                      pushl       %ebp&lt;br /&gt;    +1  00001f8d  89e5                    movl        %esp,%ebp&lt;br /&gt;    +3  00001f8f  83ec18                  subl        $0x18,%esp&lt;br /&gt;    +6  00001f92  8b4508                  movl        0x08(%ebp),%eax&lt;br /&gt;    +9  00001f95  890424                  movl        %eax,(%esp,1)&lt;br /&gt;   +12  00001f98  e8e1ffffff              calll       _func2&lt;br /&gt;   +17  00001f9d  c9                      leave&lt;br /&gt;   +18  00001f9e  c3                      ret&lt;br /&gt;&lt;br /&gt;_main:&lt;br /&gt;    +0  00001f9f  55                      pushl       %ebp&lt;br /&gt;    +1  00001fa0  89e5                    movl        %esp,%ebp&lt;br /&gt;    +3  00001fa2  83ec18                  subl        $0x18,%esp&lt;br /&gt;    +6  00001fa5  c7042401000000          movl        $0x00000001,(%esp,1)&lt;br /&gt;   +13  00001fac  e8dbffffff              calll       _func1&lt;br /&gt;   +18  00001fb1  c9                      leave&lt;br /&gt;   +19  00001fb2  c3                      ret&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Standard stuff- main calls func1, func1 calls func2. Each function's prolog pushes the base pointer onto the stack, saves the previous stack pointer as the new base pointer, and updates the stack pointer as needed for that function. And each function's epilog uses the 'leave' instruction to copy the base pointer back to the stack pointer, and pop the the old base pointer back into %ebp before returning control to the calling function. Because these functions perform this standard housekeeping, gdb can provide us with an accurate backtrace if we ask for it:&lt;br /&gt;&lt;br /&gt;&lt;pre class=".source_code"&gt;Breakpoint 1, 0x00001f84 in func2 ()&lt;br /&gt;(gdb) bt&lt;br /&gt;#0  0x00001f84 in func2 ()&lt;br /&gt;#1  0x00001f9d in func1 ()&lt;br /&gt;#2  0x00001fb1 in main ()&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;So far, so good. Now let's crank up the optimization level to -O2:&lt;br /&gt;&lt;br /&gt;&lt;pre class=".source_code"&gt;_func2:&lt;br /&gt;    +0  00001f8e  55                      pushl       %ebp&lt;br /&gt;    +1  00001f8f  89e5                    movl        %esp,%ebp&lt;br /&gt;    +3  00001f91  8b4508                  movl        0x08(%ebp),%eax&lt;br /&gt;    +6  00001f94  83e801                  subl        $0x01,%eax&lt;br /&gt;    +9  00001f97  5d                      popl        %ebp&lt;br /&gt;   +10  00001f98  c3                      ret&lt;br /&gt;&lt;br /&gt;_func1:&lt;br /&gt;    +0  00001f99  55                      pushl       %ebp&lt;br /&gt;    +1  00001f9a  89e5                    movl        %esp,%ebp&lt;br /&gt;    +3  00001f9c  5d                      popl        %ebp&lt;br /&gt;    +4  00001f9d  e9ecffffff              jmpl        0x00001f8e&lt;br /&gt;&lt;br /&gt;_main:&lt;br /&gt;    +0  00001fa2  55                      pushl       %ebp&lt;br /&gt;    +1  00001fa3  89e5                    movl        %esp,%ebp&lt;br /&gt;    +3  00001fa5  c7450801000000          movl        $0x00000001,0x08(%ebp)&lt;br /&gt;   +10  00001fac  5d                      popl        %ebp&lt;br /&gt;   +11  00001fad  e9e7ffffff              jmpl        0x00001f99&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Now we have a problem.&lt;br /&gt;&lt;br /&gt;Each function still has the usual prolog, but the epilogs have changed. There are no 'leave' instructions, and there's only one 'ret' instruction, in func2. gdb is now unable to give us an accurate backtrace:&lt;br /&gt;&lt;br /&gt;&lt;pre class=".source_code"&gt;Breakpoint 1, 0x00001f91 in func2 ()&lt;br /&gt;(gdb) bt&lt;br /&gt;#0  0x00001f91 in func2 ()&lt;br /&gt;#1  0x00001f72 in _start ()&lt;br /&gt;#2  0x00001e99 in start ()&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The stack frames from main and func1 are no longer visible in the backtrace(_start calls main in every application, though gdb may sometimes exclude it from the backtrace).&lt;br /&gt;&lt;br /&gt;There are two differences that we should note:&lt;br /&gt;&lt;br /&gt;• The mechanism by which one function transfers control to another function has changed. Under -O2 optimization, 'calll' has been replaced with 'jmpl', which is sometimes referred to as a &lt;a href="http://en.wikipedia.org/wiki/Tail_call"&gt;tail call optimization&lt;/a&gt;.&lt;br /&gt;• Each function now pops the stack into %ebp before transferring control to the called function. &lt;br /&gt;&lt;br /&gt;These differences have these results:&lt;br /&gt;&lt;br /&gt;• The return address is not updated across function calls, because 'calll' is not used(%eip is not pushed onto the stack).&lt;br /&gt;• %ebp retains its original value across function calls, because the caller pops %ebp(after it pushes %ebp in its prolog) before transferring control to the called function.&lt;br /&gt;&lt;br /&gt;Because of these changes, gdb is unable to give us an accurate backtrace. The specific flag that causes this code generation is -foptimize-sibling-calls, which is included in -O2 and higher.&lt;br /&gt;&lt;br /&gt;Depending on our needs, there are two ways to disable this optimization.&lt;br /&gt;&lt;br /&gt;• The sledgehammer: -fno-optimize-sibling-calls will prevent gcc from generating the problem code across the entire executable.&lt;br /&gt;• The scalpel: Inserting an extra line of code in a function will prevent gcc from generating the problem code on a per-function basis:&lt;br /&gt;&lt;br /&gt;&lt;pre class=".source_code"&gt;int func1(int x)&lt;br /&gt;{&lt;br /&gt;    int result = func2(x);&lt;br /&gt;    __asm__ volatile("");&lt;br /&gt;    return result;&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The asm directive tells gcc to insert whatever text we specify into the intermediate assembly file before it gets passed to the assembler. Luckily, gcc does not parse our string(s), so it has no idea what logic, if any, that we're adding. Since it appears to gcc that there is additional logic after the function call, the tail call optimization is no longer possible. &lt;strike&gt;The 'volatile' keyword prevents gcc from moving the asm directive from its current location in the function.&lt;/strike&gt;&lt;br /&gt;&lt;br /&gt;Update: The volatile keyword only prevents the compiler from moving the asm block relative to other asm blocks, not relative to other lines of C code. The above use of 'result' after the asm block is the more important detail of this code snippet. The volatile keyword is not in fact needed, and this hack is a bit more fragile than I originally thought.&lt;br /&gt;&lt;br /&gt;There is one other optimization that can result in missing stack frames: -fomit-frame-pointer. gcc's man page doesn't seem to explain which optimization levels can include this flag, but it's easy to disable it entirely with -fno-omit-frame-pointer. Another issue with -fomit-frame-pointer is that it only results in missing stack frames on some architectures. I'll leave it to the reader to explore that one.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8093909139580325869-4040614658290992626?l=yamacdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamacdev.blogspot.com/feeds/4040614658290992626/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8093909139580325869&amp;postID=4040614658290992626' title='8 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/4040614658290992626'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/4040614658290992626'/><link rel='alternate' type='text/html' href='http://yamacdev.blogspot.com/2007/09/case-of-missing-stack-frames.html' title='The Case of the Missing Stack Frames'/><author><name>Blake C.</name><uri>http://www.blogger.com/profile/08296013471634395562</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8093909139580325869.post-7671227850551094051</id><published>2007-08-24T14:47:00.000-07:00</published><updated>2007-08-24T14:50:36.449-07:00</updated><title type='text'>So Long, Chicago</title><content type='html'>I enjoyed my summer in California so much that I've decided to stick around. While I won't shed a tear for the weather, I'll miss &lt;a href="http://www.violasong.com/blog/"&gt;all&lt;/a&gt; &lt;a href="http://www.dribin.org/dave/blog/"&gt;my&lt;/a&gt; &lt;a href="http://rentzsch.com/"&gt;friends&lt;/a&gt; at &lt;a href="http://cawug.org/"&gt;CAWUG&lt;/a&gt; and &lt;a href="http://rentzsch.com/psig/"&gt;PSIG&lt;/a&gt;, but I'll try to make up for it at the &lt;a href="http://www.cocoaheads.org/us/SiliconValleyCalifornia/index.html"&gt;Silicon Valley CocoaHeads&lt;/a&gt; meetings.&lt;br /&gt;&lt;br /&gt;&amp;lt;rant&amp;gt;&lt;br /&gt;If you're a Cocoa programmer and you don't attend these regular meetings in your area, you owe it to yourself to start attending now. They are a refreshing vacation from the bleak Windows landscape, and I'm living proof that they can be an excellent career move.&lt;br /&gt;&amp;lt;/rant&amp;gt;&lt;br /&gt;&lt;br /&gt;Many thanks to Wolf, Bob Frank and everyone else for the memories. I'll try to drop in when I can...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8093909139580325869-7671227850551094051?l=yamacdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamacdev.blogspot.com/feeds/7671227850551094051/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8093909139580325869&amp;postID=7671227850551094051' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/7671227850551094051'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/7671227850551094051'/><link rel='alternate' type='text/html' href='http://yamacdev.blogspot.com/2007/08/so-long-chicago.html' title='So Long, Chicago'/><author><name>Blake C.</name><uri>http://www.blogger.com/profile/08296013471634395562</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8093909139580325869.post-4413260309323038456</id><published>2007-06-30T02:31:00.000-07:00</published><updated>2007-06-30T02:54:41.988-07:00</updated><title type='text'>Choices and Repercussions</title><content type='html'>&lt;a href="http://www.macworld.com/news/2007/06/29/iphone_crowds/index.php"&gt;People want better phones, apparently.&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;Ryan Overdevest, a 22-year-old student on a summer internship at an equity research firm, was third in line at the AT&amp;T Store. [...] “I’m here for my boss. He sent me here as soon as I got in.” Overdewest showed up for work at 6 a.m., and was in line by 6:30 Friday morning.&lt;/blockquote&gt;&lt;br /&gt;Sucks for Ryan. As a summer intern, I slept way past 6 AM, did some work, had some fun, and then went to a local Apple store to witness the iMadness firsthand.&lt;br /&gt;&lt;br /&gt;This is why I didn't major in equity research.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8093909139580325869-4413260309323038456?l=yamacdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamacdev.blogspot.com/feeds/4413260309323038456/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8093909139580325869&amp;postID=4413260309323038456' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/4413260309323038456'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/4413260309323038456'/><link rel='alternate' type='text/html' href='http://yamacdev.blogspot.com/2007/06/choices-and-repercussions.html' title='Choices and Repercussions'/><author><name>Blake C.</name><uri>http://www.blogger.com/profile/08296013471634395562</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8093909139580325869.post-8747754058189542017</id><published>2007-06-26T22:29:00.000-07:00</published><updated>2007-06-26T22:41:00.849-07:00</updated><title type='text'>Apologies, More Posts Soon...</title><content type='html'>Forgive me, folks- there's barely enough time to keep up with the latest iPhone hype/bashing/speculation/foolishness, and I can't seem to get any posts together lately. Maybe next week.&lt;br /&gt;&lt;br /&gt;Meanwhile, let's all chip in and send Gruber some ink for his jackass stamp. He won't last the next 3 days without us...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8093909139580325869-8747754058189542017?l=yamacdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamacdev.blogspot.com/feeds/8747754058189542017/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8093909139580325869&amp;postID=8747754058189542017' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/8747754058189542017'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/8747754058189542017'/><link rel='alternate' type='text/html' href='http://yamacdev.blogspot.com/2007/06/apologies-more-posts-soon.html' title='Apologies, More Posts Soon...'/><author><name>Blake C.</name><uri>http://www.blogger.com/profile/08296013471634395562</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8093909139580325869.post-2941847766419119179</id><published>2007-06-09T22:53:00.000-07:00</published><updated>2007-06-09T22:54:19.472-07:00</updated><title type='text'>Another True Story</title><content type='html'>Me: "blah blah Jonathan Schwartz blah."&lt;br /&gt;&lt;br /&gt;My Friend: "Who?"&lt;br /&gt;&lt;br /&gt;Me: "My Little Pony."&lt;br /&gt;&lt;br /&gt;My Friend: "Oh."&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8093909139580325869-2941847766419119179?l=yamacdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamacdev.blogspot.com/feeds/2941847766419119179/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8093909139580325869&amp;postID=2941847766419119179' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/2941847766419119179'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/2941847766419119179'/><link rel='alternate' type='text/html' href='http://yamacdev.blogspot.com/2007/06/another-true-story.html' title='Another True Story'/><author><name>Blake C.</name><uri>http://www.blogger.com/profile/08296013471634395562</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8093909139580325869.post-5617137604809961028</id><published>2007-05-31T22:54:00.000-07:00</published><updated>2007-05-31T23:53:05.151-07:00</updated><title type='text'>C is to Wolf as D is to Goat</title><content type='html'>&lt;a href="http://en.wikipedia.org/wiki/Z1_(computer)"&gt;Z1&lt;/a&gt;, &lt;a href="http://www.a2-web.com"&gt;A2&lt;/a&gt;, &lt;a href="http://www.b3toledo.com"&gt;B3&lt;/a&gt;, &lt;a href="http://www.rentzsch.com/c4/"&gt;C4&lt;/a&gt;, &lt;a href="http://d5.allthingsd.com/"&gt;D5&lt;/a&gt;, &lt;a href="http://www.motorola.com/motoinfo/product/details.jsp?globalObjectId=175"&gt;E6&lt;/a&gt;, &lt;a href="http://www.michaellarabel.com/?k=blog&amp;i=35"&gt;F7&lt;/a&gt;, &lt;a href="http://www.g8reboot.net"&gt;G8&lt;/a&gt;...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8093909139580325869-5617137604809961028?l=yamacdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamacdev.blogspot.com/feeds/5617137604809961028/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8093909139580325869&amp;postID=5617137604809961028' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/5617137604809961028'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/5617137604809961028'/><link rel='alternate' type='text/html' href='http://yamacdev.blogspot.com/2007/05/c-is-to-wolf-as-d-is-to-goat.html' title='C is to Wolf as D is to Goat'/><author><name>Blake C.</name><uri>http://www.blogger.com/profile/08296013471634395562</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8093909139580325869.post-8114886608575898815</id><published>2007-05-20T20:00:00.000-07:00</published><updated>2007-05-25T01:04:39.816-07:00</updated><title type='text'>WWDC Anyone?</title><content type='html'>I'm going this year, and I've been told there may be others in attendance as well. If you are one such other and you share my interest in beer and/or whiskey, gimme a shout here.&lt;br /&gt;&lt;br /&gt;Update: Either I will be alone at WWDC or I'm the only alcoholic who reads my blog.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8093909139580325869-8114886608575898815?l=yamacdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamacdev.blogspot.com/feeds/8114886608575898815/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8093909139580325869&amp;postID=8114886608575898815' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/8114886608575898815'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/8114886608575898815'/><link rel='alternate' type='text/html' href='http://yamacdev.blogspot.com/2007/05/wwdc-anyone.html' title='WWDC Anyone?'/><author><name>Blake C.</name><uri>http://www.blogger.com/profile/08296013471634395562</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8093909139580325869.post-5859072775827498700</id><published>2007-05-09T23:13:00.000-07:00</published><updated>2007-05-29T01:27:44.495-07:00</updated><title type='text'>Display Eater Update</title><content type='html'>We had some &lt;a href="http://yamacdev.blogspot.com/2007/02/behind-curtain-with-display-eater.html"&gt;interesting&lt;/a&gt; &lt;a href="http://yamacdev.blogspot.com/2007/02/open-letter-regarding-display-eater.html"&gt;discussions&lt;/a&gt; with Reza recently, and I thought I should check in with him. Let's see what he's up to:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.reversecode.com/"&gt;http://www.reversecode.com/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;It now redirects to &lt;a href="http://sio.midco.net/haunted/"&gt;sio.midco.net&lt;/a&gt;, and I find myself in the awkward position of introducing the blogosphere to &lt;a href="http://sio.midco.net/haunted/LED%20PIX/"&gt;LED pron&lt;/a&gt;. (I'm too scared to download the dmg.)&lt;br /&gt;&lt;br /&gt;Hopefully, Reza's site got hacked. I can't even imagine the alternatives.&lt;br /&gt;&lt;br /&gt;Reza, feel free to comment here and let us know what's going on.&lt;br /&gt;&lt;br /&gt;Update: The LED pron has been replaced by &lt;a href="http://sio.midco.net/haunted/FINISHED_/FINISHED_/"&gt;weed pron&lt;/a&gt; and the previous URL is 404. Still waiting for Reza to reply here...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8093909139580325869-5859072775827498700?l=yamacdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamacdev.blogspot.com/feeds/5859072775827498700/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8093909139580325869&amp;postID=5859072775827498700' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/5859072775827498700'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/5859072775827498700'/><link rel='alternate' type='text/html' href='http://yamacdev.blogspot.com/2007/05/display-eater-update.html' title='Display Eater Update'/><author><name>Blake C.</name><uri>http://www.blogger.com/profile/08296013471634395562</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8093909139580325869.post-6612632745896232612</id><published>2007-04-23T21:03:00.000-07:00</published><updated>2007-04-29T23:59:23.457-07:00</updated><title type='text'>Run, Forrest, Run!</title><content type='html'>One day, for no paticalar reason, I started runnin. I ran all the way to the end of Chicago. And since I run that far, I kept on runnin, clear across the great state of Illinois. And you know what? I ran all the way to California, and got me a internship at some fruit companay.&lt;br /&gt;&lt;br /&gt;I sure hope Jennay can come visit me. I hear they have lotsa them special cigarrets she likes so much.&lt;br /&gt;&lt;br /&gt;Update: Ridiculous Fish &lt;a href="http://ridiculousfish.com/blog/archives/2007/04/13/42/"&gt;beats me&lt;/a&gt; at my own movie-referencing game, and 10 days earlier to boot. If my calculations are correct, this will inspire a wildly popular Forrest Gump/LOTR mashup that youtube will promptly delete.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8093909139580325869-6612632745896232612?l=yamacdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamacdev.blogspot.com/feeds/6612632745896232612/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8093909139580325869&amp;postID=6612632745896232612' title='10 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/6612632745896232612'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/6612632745896232612'/><link rel='alternate' type='text/html' href='http://yamacdev.blogspot.com/2007/04/run-forrest-run.html' title='Run, Forrest, Run!'/><author><name>Blake C.</name><uri>http://www.blogger.com/profile/08296013471634395562</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>10</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8093909139580325869.post-850135298223304820</id><published>2007-04-18T22:50:00.000-07:00</published><updated>2007-04-18T22:51:16.900-07:00</updated><title type='text'>C'mon In, The Water's Fine.</title><content type='html'>A big warm welcome to &lt;a href="http://www.codebeach.org/"&gt;CodeBeach&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;The goal of this site is to create a central repository where Mac developers can share pieces of useful code (like custom controls, formatters, categories) which is easier to search/use than forums or mailing lists.&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;This is way overdue. An OS X opensource &lt;i&gt;public domain&lt;/i&gt; repository of freely re-usable code, with no bullshit licenses to muck things up. These guys have the right idea, and I urge everyone to contribute what they can, if at all possible.&lt;br /&gt;&lt;br /&gt;Many thanx to &lt;a href="http://www.briksoftware.com/blog/"&gt;briksoftware&lt;/a&gt; for creating this.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8093909139580325869-850135298223304820?l=yamacdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamacdev.blogspot.com/feeds/850135298223304820/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8093909139580325869&amp;postID=850135298223304820' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/850135298223304820'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/850135298223304820'/><link rel='alternate' type='text/html' href='http://yamacdev.blogspot.com/2007/04/cmon-in-waters-fine.html' title='C&apos;mon In, The Water&apos;s Fine.'/><author><name>Blake C.</name><uri>http://www.blogger.com/profile/08296013471634395562</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8093909139580325869.post-2416148405708674656</id><published>2007-03-28T21:13:00.000-07:00</published><updated>2007-03-28T21:15:19.579-07:00</updated><title type='text'>How To Tell If You're A Mac Geek</title><content type='html'>When a cute girl says she's interested in studying computer science, she goes from cute to pretty.&lt;br /&gt;&lt;br /&gt;When she whips out a MacBook Pro, she goes from pretty to beautiful.&lt;br /&gt;&lt;br /&gt;When she mentions that she's a certified Apple hardware tech, she goes from beautiful to fucking gorgeous.&lt;br /&gt;&lt;br /&gt;True story. Disturbing, but true.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8093909139580325869-2416148405708674656?l=yamacdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamacdev.blogspot.com/feeds/2416148405708674656/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8093909139580325869&amp;postID=2416148405708674656' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/2416148405708674656'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/2416148405708674656'/><link rel='alternate' type='text/html' href='http://yamacdev.blogspot.com/2007/03/how-to-tell-if-youre-mac-geek.html' title='How To Tell If You&apos;re A Mac Geek'/><author><name>Blake C.</name><uri>http://www.blogger.com/profile/08296013471634395562</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8093909139580325869.post-5384731405423652392</id><published>2007-03-23T00:54:00.000-07:00</published><updated>2007-03-23T01:30:52.171-07:00</updated><title type='text'>The BOOLs, They Do Nothing</title><content type='html'>From &amp;lt;CarbonCore/MacTypes.h&amp;gt:&lt;br /&gt;&lt;pre class=".source_code"&gt;// kInvalidID  KernelID: NULL is for pointers as kInvalidID is for ID's&lt;br /&gt;&lt;br /&gt;#define kInvalidID 0&lt;/pre&gt;&lt;br /&gt;So I should say-&lt;br /&gt;&lt;br /&gt;&lt;pre class=".source_code"&gt;if (someID == kInvalidID)&lt;/pre&gt;&lt;br /&gt;instead of-&lt;br /&gt;&lt;br /&gt;&lt;pre class=".source_code"&gt;if (!someID) ?&lt;/pre&gt;&lt;br /&gt;OK yea, I'll get right on that.&lt;br /&gt;&lt;br /&gt;Seriously, every time i start to think that NS X rocks, I find some lameass redefinition like this. Zero is zero- am I missing something? Is this really just a Carbon relic, as the filename implies? Is it going away soon?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8093909139580325869-5384731405423652392?l=yamacdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamacdev.blogspot.com/feeds/5384731405423652392/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8093909139580325869&amp;postID=5384731405423652392' title='8 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/5384731405423652392'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/5384731405423652392'/><link rel='alternate' type='text/html' href='http://yamacdev.blogspot.com/2007/03/bools-they-do-nothing.html' title='The BOOLs, They Do Nothing'/><author><name>Blake C.</name><uri>http://www.blogger.com/profile/08296013471634395562</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8093909139580325869.post-1974697148335843051</id><published>2007-03-13T21:13:00.000-07:00</published><updated>2007-03-13T21:27:42.602-07:00</updated><title type='text'>Obfuscated Me</title><content type='html'>So I was over at &lt;a href="http://theocacao.com"&gt;Scott Stevenson's internet&lt;/a&gt; recently and was surprised to &lt;a href="http://theocacao.com/document.page/437"&gt;see&lt;/a&gt; not only my name, but an eerily spot-on description of me:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;Now Blake, on the other hand; he's a riddle wrapped in a mystery inside an enigma passed to an instance of NSInvocation.&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;The only thing Bagelturf missed was that I'm usually just invoked with performSelector: - I'm not very complicated. As for the riddle, it's just @encode().&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8093909139580325869-1974697148335843051?l=yamacdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamacdev.blogspot.com/feeds/1974697148335843051/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8093909139580325869&amp;postID=1974697148335843051' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/1974697148335843051'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/1974697148335843051'/><link rel='alternate' type='text/html' href='http://yamacdev.blogspot.com/2007/03/obfuscated-me.html' title='Obfuscated Me'/><author><name>Blake C.</name><uri>http://www.blogger.com/profile/08296013471634395562</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8093909139580325869.post-3565777747837292025</id><published>2007-03-08T22:25:00.000-08:00</published><updated>2007-03-15T02:04:55.818-07:00</updated><title type='text'>A Tale of Two CPUs</title><content type='html'>&lt;b&gt;Exploring and comparing "Accelerated Objective-C Dispatch" on PPC and x86&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Links to Darwin source in this post require an Apple ID. They're free, so get one.&lt;br /&gt;&lt;br /&gt;I learned about the Obj-C runtime pages last year, and was reminded by &lt;a href="http://lists.apple.com/archives/xcode-users/2005/Sep/msg00439.html"&gt;this post&lt;/a&gt; to one of Apple's mailing lists. Mr. Maebe did a great job of explaining things, but there's always more to the story.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;u&gt;Who 0xfffeff00 is&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Mr. Feffoo is a copy of the _objc_msgSend assembly routine defined in &lt;a href="http://www.opensource.apple.com/darwinsource/10.4.8.ppc/objc4-267.1/runtime/Messengers.subproj/objc-msg-ppc.s"&gt;objc-msg-ppc.s&lt;/a&gt;. As Mr. Maebe pointed out, the only documentation is the source code. The easiest way to find it is to &lt;a href="http://www.google.com/search?hl=en&amp;q=0xfffeff00&amp;btnG=Google+Search"&gt;google 0xfffeff00&lt;/a&gt;. Apple's policy of requiring a login to view their source code seems to keep google's spider at bay, but our old dead friend, DarwinSource, is still cached. The first found occurrence of 0xfffeff00 is in &lt;a href="http://www.opensource.apple.com/darwinsource/10.4.8.ppc/objc4-267.1/runtime/objc-rtp.h"&gt;objc-rtp.h&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&amp;lt;side note&amp;gt;&lt;br /&gt;While we're looking at _objc_msgSend, I'd like to remind everyone who says "messaging nil objects returns nil" that our friend Peter Ammon &lt;a href="http://ridiculousfish.com/blog/archives/2005/05/29/nil/"&gt;showed us&lt;/a&gt; that this is not always the case. If your code makes that assumption, it wouldn't hurt to fix it now.&lt;br /&gt;&amp;lt;/side note&amp;gt;&lt;br /&gt;&lt;br /&gt;Notice that this is the PPC version of Darwin. 0xfffeff00 is the value assigned to kRTAddress_objc_msgSend, but only for PPC. While this header file is very interesting, its associated &lt;a href="http://www.opensource.apple.com/darwinsource/10.4.8.ppc/objc4-267.1/runtime/objc-rtp.m"&gt;source file&lt;/a&gt; is the real fun:&lt;br /&gt;&lt;br /&gt;&lt;pre class=".source_code"&gt;/*&lt;br /&gt;  objc-rtp.m&lt;br /&gt;  Copyright 2004, Apple Computer, Inc.&lt;br /&gt;  Author: Jim Laskey&lt;br /&gt;  &lt;br /&gt;  Implementation of the "objc runtime pages", an fixed area &lt;br /&gt;  in high memory that can be reached via an absolute branch.&lt;br /&gt;*/&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Hat's off to Mr. Laskey for this file. In my opinion, what happens herein is some of the most interesting code in Darwin. I'll leave it to the reader to enjoy the code that actually &lt;i&gt;copies the _objc_msgSend routine to high memory&lt;/i&gt;. Code that treats code like the data it is always makes me smile.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;u&gt;PPC Limits Set&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The magic number here is 0xffff8000. Above this address lie the "comm pages", the documentation for which eludes me now(anyone?). The reason this address is important is that a PPC absolute conditional branch can reach any address at or above it, thereby allowing the OS or kernel to copy some commonly used functions to those virtual memory pages.&lt;br /&gt;&lt;br /&gt;In the &lt;a href="http://www.freescale.com/files/product/doc/MPCFPE32B.pdf"&gt;Programming Environments Manual&lt;/a&gt;, 'bc', 'bca', 'bcl', and 'bcla' instructions are defined as having a 14 bit address field concatenated with two low zero bits, so that the destination address is guaranteed to be a multiple of four. That means that this is effectively a 16 bit address field. While 'bc' and 'bcl' have their charms, we're more interested in the absolute variants.&lt;br /&gt;&lt;br /&gt;If we set the high bit, or sign bit, of the address field and clear the lower bits, the CPU's sign extension produces the number 0xffff8000. And if we use the absolute variants 'bca' and 'bcla', we can branch to that address directly(as opposed to our current address minus 0x8000).&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;u&gt;PPC Limits Broken&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The comm pages are nice, but they're already used for standard ANSI and/or Unix C functions, not Apple's Obj-C stuff. So how does Apple implement similar behavior for common Obj-C runtime routines like _objc_msgSend?&lt;br /&gt;&lt;br /&gt;Simple- build more comm pages below the ones that already exist, and use a branch instruction with a broader range that can reach those addresses.&lt;br /&gt;&lt;br /&gt;Assuming you're viewing the conditional branch documentation in the PEM, scroll up a bit to the unconditional branch instructions, specifically 'ba' and 'bla'. Notice the 24 bits available in the destination address field. This field is also concatenated with 2 low zeroes, which effectively gives us 26 bits. (Sure, we could use 'bcctr' to get a full 32 bits, but that would require 2 extra instructions to load the address and would clobber the count register.)&lt;br /&gt;&lt;br /&gt;So, if we sacrifice the ability to branch conditionally, we gain 10 bits, or 1024 bytes of addressability*. If we use the unconditional branch instructions, we can branch to anywhere at or above 0xfe000000, which is well below the addresses of the routines defined in objc-rtp.m.&lt;br /&gt;&lt;br /&gt;Jackpot.&lt;br /&gt;&lt;br /&gt;The _objc_msgSend assembly routine is copied into high RAM at launch time, and PPC code that was compiled with Xcode's "Accelerated Objective-C Dispatch" option uses the high-RAM version of _objc_msgSend instead of the usual symbol stub.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;u&gt;Intel Wins For Once&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;I don't like x86 assembly and machine code any more than the next guy, but here's something that doesn't suck about the Intel chips:&lt;br /&gt;&lt;br /&gt;Darwin x86 has no runtime pages, because it doesn't need them. Not being able to load a 32 bit number in a single instruction is a limitation of the PPC ISA that Intel doesn't share. &lt;i&gt;x86 Obj-C code is "accelerated" by design&lt;/i&gt;, and the "Accelerated Objective-C Dispatch" option has no effect whatsoever. Since they don't need symbol stubs, they don't need the "accelerated" workaround.&lt;br /&gt;&lt;br /&gt;It's not inconceivable that the "Accelerated Objective-C Dispatch" option will only exist for as long as Apple supports PPC machines.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;u&gt;One More Thing™&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Though it's only loosely related to this article, it's interesting to note the following code from objc-rtp.m:&lt;br /&gt;&lt;br /&gt;&lt;pre class=".source_code"&gt;&lt;br /&gt; // initialize code in ObjC runtime pages&lt;br /&gt; rtp_set_up_objc_msgSend(kRTAddress_objc_msgSend, kRTSize_objc_msgSend);&lt;br /&gt;    &lt;br /&gt; rtp_set_up_other(kRTAddress_objc_assign_ivar, kRTSize_objc_assign_ivar,&lt;br /&gt;  "objc_assign_ivar", objc_assign_ivar_gc, objc_assign_ivar_non_gc);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;An entire function to assign a value to an instance variable? And an optimized version at that? Hmm.&lt;br /&gt;&lt;br /&gt;While I currently have no NDA obligation with Apple, I've been told that the information at which this code hints is hush-hush for now. So, out of respect for The Masters, I will only direct the reader to Xcode's "Project Settings" window. Specifically, the description of the "-fobjc-gc" flag.&lt;br /&gt;&lt;br /&gt;For those who don't want to fish around for details, "gc" stands for "Great Code".&lt;br /&gt;&lt;br /&gt;Many thanks to Mr. Laskey, Mr. Ammon, and all of the Apple coders working on the Obj-C runtime. Our applications only execute correctly and easily because you have all applied an enormous effort in designing a crucial part of the OS X underbelly. We all appreciate your work.&lt;br /&gt;&lt;br /&gt;If any of you attend C4[1], the drinks are on me.&lt;br /&gt;&lt;br /&gt;* I meant to say 33,521,664 bytes, not 1024 bytes. Minor oversight, sorry about that.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8093909139580325869-3565777747837292025?l=yamacdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamacdev.blogspot.com/feeds/3565777747837292025/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8093909139580325869&amp;postID=3565777747837292025' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/3565777747837292025'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/3565777747837292025'/><link rel='alternate' type='text/html' href='http://yamacdev.blogspot.com/2007/03/tale-of-two-cpus.html' title='A Tale of Two CPUs'/><author><name>Blake C.</name><uri>http://www.blogger.com/profile/08296013471634395562</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8093909139580325869.post-1214003836881376041</id><published>2007-03-05T23:28:00.000-08:00</published><updated>2007-11-30T18:08:45.403-08:00</updated><title type='text'>Free Noob Lesson #2</title><content type='html'>We've all done this-&lt;br /&gt;&lt;br /&gt;&lt;pre class=".source_code"&gt;- (id)init&lt;br /&gt;{&lt;br /&gt;    if (!(self = [super init]))&lt;br /&gt;        return nil;&lt;br /&gt;&lt;br /&gt;    // etc.&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;That obviously returns nil when [super init] fails.&lt;br /&gt;&lt;br /&gt;But what if you accidentally add(or forget to remove) an extra semicolon?&lt;br /&gt;&lt;br /&gt;&lt;pre class=".source_code"&gt;- (id)init&lt;br /&gt;{&lt;br /&gt;    if (!(self = [super init]));&lt;br /&gt;        return nil;&lt;br /&gt;&lt;br /&gt;    // etc.&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;GCC is perfectly happy with that, but your application is not. The above code reduces to this useless logic:&lt;br /&gt;&lt;br /&gt;&lt;pre class=".source_code"&gt;- (id)init&lt;br /&gt;{&lt;br /&gt;    self = [super init];&lt;br /&gt;&lt;br /&gt;    return nil;&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;One might say that we could avoid this by returning self instead of nil, but then the code in 'etc.' would still never be executed, and the resulting bug would probably be much harder to locate.&lt;br /&gt;&lt;br /&gt;The only quick and easy protection that I can think of is sobriety, which is clearly out of the question. Any thoughts?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8093909139580325869-1214003836881376041?l=yamacdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamacdev.blogspot.com/feeds/1214003836881376041/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8093909139580325869&amp;postID=1214003836881376041' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/1214003836881376041'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/1214003836881376041'/><link rel='alternate' type='text/html' href='http://yamacdev.blogspot.com/2007/03/free-noob-lesson-2.html' title='Free Noob Lesson #2'/><author><name>Blake C.</name><uri>http://www.blogger.com/profile/08296013471634395562</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8093909139580325869.post-1299303113810825030</id><published>2007-02-25T23:31:00.000-08:00</published><updated>2007-02-25T23:40:23.333-08:00</updated><title type='text'>Open Letter Regarding Display Eater</title><content type='html'>&lt;b&gt;To Reza Hussain:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;There is a lack of official information about versions of Display Eater that predate version 1.85, which is the version I decompiled. You were interviewed by a &lt;a href="http://macnytt.se/news/10093"&gt;Swedish web site&lt;/a&gt;, and allegedly provided the information we are looking for, but the English translation of that interview is currently only available through a &lt;a href="http://www.rixstep.com/1/20070225,00.shtml"&gt;third party&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Reza, I respectfully request an answer to this question:&lt;br /&gt;&lt;br /&gt;Did previous versions of Display Eater delete files and/or folders other than your own Application Support folder?&lt;br /&gt;&lt;br /&gt;I recognize that version 1.85 only deletes files that your app created, and I only ask this question to provide facts to the Mac community, and to conclude this sad chapter of our shared history.&lt;br /&gt;&lt;br /&gt;Be assured that I am not interested in harassing you, whatever your answer may be. We just want to know the truth. In the interest of preserving what is left of your good reputation, please enlighten us, in English.&lt;br /&gt;&lt;br /&gt;Thank you.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;To everyone else:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The comments to this post are reserved for Reza, and polite commenters. Inflammatory comments will be removed, as there are &lt;a href="http://slashdot.org/"&gt;countless&lt;/a&gt; &lt;a href="http://www.digg.com/"&gt;other&lt;/a&gt; &lt;a href="http://www.versiontracker.com/"&gt;outlets&lt;/a&gt; for those sentiments.&lt;br /&gt;&lt;br /&gt;Thank you.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8093909139580325869-1299303113810825030?l=yamacdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamacdev.blogspot.com/feeds/1299303113810825030/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8093909139580325869&amp;postID=1299303113810825030' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/1299303113810825030'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/1299303113810825030'/><link rel='alternate' type='text/html' href='http://yamacdev.blogspot.com/2007/02/open-letter-regarding-display-eater.html' title='Open Letter Regarding Display Eater'/><author><name>Blake C.</name><uri>http://www.blogger.com/profile/08296013471634395562</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8093909139580325869.post-4141843039164231146</id><published>2007-02-24T23:43:00.000-08:00</published><updated>2007-11-30T18:10:50.603-08:00</updated><title type='text'>Behind The Curtain With Display Eater</title><content type='html'>You may have seen the &lt;a href="http://briksoftware.com/blog/?p=25#comment-418"&gt;discussion&lt;/a&gt; recently about an app called Display Eater by Reza Hussain. &lt;strike&gt;While the author has not responded to the latest discussion, he &lt;a href="http://www.versiontracker.com/dyn/moreinfo/macosx/26767"&gt;allegedly&lt;/a&gt; admitted that the whole thing was a hoax to deter potential pirates.&lt;/strike&gt; Reza has just replied with a &lt;a href="http://reversecode.com/"&gt;public letter&lt;/a&gt;. While the discussion has been lively, the investigation has been nonexistant. So here it is.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;First, the legal stuff:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;According to the Display Eater 1.8.5 license agreement:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;3. License Restrictions&lt;br /&gt;b. You may not alter, merge, modify, adapt or translate the Software, or decompile, reverse engineer, disassemble, or otherwise reduce the Software to a human-perceivable form.&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;But I wanted to disassemble the app! Fortunately, the license is not really a legal agreement:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;THIS SOFTWARE END USER LICENSE AGREEMENT(EULA) IS A LEGA AGREEMENT BETWEEN YOU(EITHER AN INDIVIDUAL OR, IF PURCHASED OR OTHERWISE AQUIRED BY OR FOR AN ENTITY, AN ENTITY) AND THE AUTHOR OF THIS SOFTWARE.&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;Since LEGA AGREEMENTs don't hold up in court, we're free to do what we want with the app*. I'd also like to suggest to &lt;a href="http://geekpatrol.ca/2007/02/display-eater-eats-more-than-just-displays"&gt;John Stansbury&lt;/a&gt; that while his assertion that users don't have the right to reverse engineer an app is correct in most cases, it's not applicable here, for the above reason.&lt;br /&gt;&lt;br /&gt;Reza, fix your license.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Second, the fun stuff:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;This is one of those apps that writes copious amounts of crap to the console for no reason. For example, after simply launching the app, declining to register, and quitting, I got this:&lt;br /&gt;&lt;br /&gt;display_eater[3338] help me Start Recording&lt;br /&gt;display_eater[3338] no file&lt;br /&gt;display_eater[3338] mmmkay&lt;br /&gt;display_eater[3338] mmmmm&lt;br /&gt;display_eater[3338] selfmutilation DVC PAL&lt;br /&gt;display_eater[3338] lettesta /Applications/Display Eater 1.85/Display Eater.app/Contents/Resources/cursor2.gif&lt;br /&gt;display_eater[3338] onenationunderfuck 640x480&lt;br /&gt;display_eater[3338] cheated--20 fps&lt;br /&gt;display_eater[3338] loadedrender&lt;br /&gt;&lt;br /&gt;Yes, that says onenationunderfuck. In my console log. Is it still cursing if you don't use camelCase? Well, at least he's a South Park fan. Here are a few other nice ones I found in the disassembly:&lt;br /&gt;&lt;br /&gt;This "emailDeveloper:" method doesn't actually send any mail, but at least it further pollutes my log.&lt;br /&gt;&lt;br /&gt;&lt;pre class=".source_code"&gt;-(void)[mainWindowController emailDeveloper:]&lt;br /&gt;3c600003    lis      r3,0x3&lt;br /&gt;38639500    addi     r3,r3,0x9500     emailz0r&lt;br /&gt;4801e6d8    b        0x21bd0          _NSLog&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;And from other methods:&lt;br /&gt;&lt;br /&gt;&lt;pre class=".source_code"&gt;386395e0    addi     r3,r3,0x95e0     FATTTTTTTTTY&gt;&gt;&gt;&gt;&gt;&gt;&gt;&lt;br /&gt;4801e005    bl       0x21bd0          _NSLog&lt;br /&gt;&lt;br /&gt;386395a0    addi     r3,r3,0x95a0     not saved lol&lt;br /&gt;4801e1a1    bl       0x21bd0          _NSLog&lt;br /&gt;&lt;br /&gt;3863a5a0    addi     r3,r3,0xa5a0     lawl&lt;br /&gt;4800f438    b        0x21bd0          _NSLog&lt;br /&gt;&lt;br /&gt;3863b2c0    addi     r3,r3,0xb2c0     OMGFWTFBBQxinFINITY&lt;br /&gt;48003ee8    b        0x21bd0          _NSLog&lt;br /&gt;&lt;br /&gt;38639e60    addi     r3,r3,0x9e60     SDKNLLLLLLLLLLLLL&lt;br /&gt;480161d5    bl       0x21bd0          _NSLog&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;And on and on and on. People, mescaline can be loads of fun, but it's not conducive to a healthy programming environment.&lt;br /&gt;&lt;br /&gt;Ok, so Reza likes to make jokes at the expense of my log file, but that's not a capital offense. Allegedly deleting user data should be. While we're talking about spurious log data, I should note that Display Eater &lt;i&gt;actually logs the customer's name, email and serial number on every launch&lt;/i&gt;. I'll give you one guess why that's a Bad Idea™.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Finally, the good stuff:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Ok, so Reza beat me to the punch by admitting that Display Eater does not really delete your home directory. But it does delete something, and those users who watch their console logs already know what it is. I had planned to present the complete annotated assembly of the methods involved, but that would bloat this post incredibly and bore most of you. Here's a higher level explanation:&lt;br /&gt;&lt;br /&gt;The C function that does the deleting is called "destroy". In otool or otx output, search for "_destroy:". Its C declaration would look like this:&lt;br /&gt;&lt;br /&gt;&lt;pre class=".source_code"&gt;void destroy(NSString* inString);&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;It is called only from itself, and from one Obj-C method in the "recordCreateController" class:&lt;br /&gt;&lt;br /&gt;&lt;pre class=".source_code"&gt;- (id)addRecordWithPath: (NSString*)inPath&lt;br /&gt;                andRect: (NSRect*)inRect;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;(class-dump says inPath should be of type "id" but the code in Display Eater assumes an NSString*. We'll have to wait for the GPL'd code, but I suspect this is just more sloppy code- see below for the rest)&lt;br /&gt;&lt;br /&gt;In the disassembled code, "addRecordWithPath:andRect:" immediately follows "_destroy:".&lt;br /&gt;&lt;br /&gt;Note the interestingly named "emptyEntireClipOnAllOfThem" that follows "addRecordWithPath:andRect:". While it smacks of gangland violence, it is not involved with deleting any files. My good conscience prevents me from revealing its purpose :)&lt;br /&gt;&lt;br /&gt;So, when does "addRecordWithPath:andRect:" call "destroy"? The Obj-C code looks something like this:&lt;br /&gt;&lt;br /&gt;&lt;pre class=".source_code"&gt;    id  delegate = [[NSApplication sharedApplication] delegate];&lt;br /&gt;&lt;br /&gt;    // Reza, you may want to call [delegate respondsToSelector:] first...&lt;br /&gt;    NSString*   support = [delegate applicationSupportFolder];&lt;br /&gt;&lt;br /&gt;    // "ninjakiller" is the reg file.&lt;br /&gt;    // Reza, use stringByAppendingPathComponent, mmmkay?&lt;br /&gt;    NSString*   regFile = [support stringByAppendingString: @"/ninjakiller"]&lt;br /&gt;    NSArray*    regArray = [NSUnarchiver unarchiveObjectWithFile: regFile];&lt;br /&gt;&lt;br /&gt;    if (![[regArray objectAtIndex: 1] compare: @"Special [K]"] ||&lt;br /&gt;        ![[regArray objectAtIndex: 1] compare: @"KCN"])&lt;br /&gt;    {&lt;br /&gt;        NSLog(@"BUT I FALTER");&lt;br /&gt;        destroy(@"~/Library/Application Support/display_eater/");&lt;br /&gt;&lt;br /&gt;        // and then show the pirate dialog...&lt;br /&gt;    }&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Ok, nothing surprising. Whoever Special [K](nice name, btw) and KCN are, they're screwed. So what happens inside "destroy"? It seems clear already that Display Eater's app support folder will get nuked, but is that all that happens?&lt;br /&gt;&lt;br /&gt;&lt;pre class=".source_code"&gt;void destroy(NSString* inString)&lt;br /&gt;{&lt;br /&gt;    NSFileManager*  manager = [NSFileManager defaultManager];&lt;br /&gt;&lt;br /&gt;    NSString*       path = [inString stringByExpandingTildeInPath];&lt;br /&gt;    // Believe it or not, 'path' is only used for the following call.&lt;br /&gt;&lt;br /&gt;    NSArray*        files = [manager directoryContentsAtPath: path];&lt;br /&gt;    unsigned int    curFile; // I assume this is unsigned.&lt;br /&gt;&lt;br /&gt;    for (curFile = 0; curFile &lt; [files count]; curFile++)&lt;br /&gt;    {&lt;br /&gt;        // Reza, you've already expanded this- you don't need to do it twice.&lt;br /&gt;        NSString*   basePath = [inString stringByExpandingTildeInPath];&lt;br /&gt;        NSString*   curFileName = [files objectAtIndex: curFile];&lt;br /&gt;&lt;br /&gt;        // Reza, please use stringByAppendingPathComponent.&lt;br /&gt;        NSString*   curPath = [NSString stringWithFormat: @"%@/%@"&lt;br /&gt;            basePath, curFileName];&lt;br /&gt;&lt;br /&gt;        NSLog(@"%@", curPath);&lt;br /&gt;&lt;br /&gt;        // Reza, you did this already...&lt;br /&gt;        NSFileManager*  manager2 = [NSFileManager defaultManager];&lt;br /&gt;&lt;br /&gt;        // ...and this, too.&lt;br /&gt;        // I'm not sure why passing just the name and not the path works,&lt;br /&gt;        //   but it does.&lt;br /&gt;        if ([manager2 isDeletableFileAtPath: [files objectAtIndex: curFile]])&lt;br /&gt;        {&lt;br /&gt;            // Calling default manager yet again. At least we're using&lt;br /&gt;            //   the full path this time.&lt;br /&gt;            [[NSFileManager defaultManager]&lt;br /&gt;                removeFileAtPath: curPath handler: nil];&lt;br /&gt;            NSLog(@"DELETABLE");&lt;br /&gt;        }&lt;br /&gt;        else&lt;br /&gt;        {&lt;br /&gt;            destroy(curPath);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;So there it is. Display Eater recursively deletes the contents of its own Application Support folder(but not the folder itself), and nothing else. If the user was silly enough to put anything in that folder, it would have been nuked. But in that case, one might argue that they deserved it.&lt;br /&gt;&lt;br /&gt;Note that the "piratekiller" file, whose contents seem to indicate a perverted TCL function call(kilo transform ar reza) is never used for anything.&lt;br /&gt;&lt;br /&gt;Ultimately, the worst thing about this app is the sloppy Obj-C code. Reza, I would be happy to optimize your code a bit, if you're so inclined.&lt;br /&gt;&lt;br /&gt;* I'm no lawyer- if anyone can prove me wrong about this point, please do so.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8093909139580325869-4141843039164231146?l=yamacdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamacdev.blogspot.com/feeds/4141843039164231146/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8093909139580325869&amp;postID=4141843039164231146' title='22 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/4141843039164231146'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/4141843039164231146'/><link rel='alternate' type='text/html' href='http://yamacdev.blogspot.com/2007/02/behind-curtain-with-display-eater.html' title='Behind The Curtain With Display Eater'/><author><name>Blake C.</name><uri>http://www.blogger.com/profile/08296013471634395562</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>22</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8093909139580325869.post-4362687134697992052</id><published>2007-02-22T22:41:00.000-08:00</published><updated>2007-02-23T00:34:03.298-08:00</updated><title type='text'>Another Link Post</title><content type='html'>Lately, I've had better luck with links than real info, and I've recently come across a webcomic that most of you will enjoy. &lt;a href="http://xkcd.com/c149.html"&gt;Here's a taste&lt;/a&gt;. OK, &lt;a href="http://xkcd.com/c138.html"&gt;one more&lt;/a&gt;. And be careful &lt;a href="http://xkcd.com/c118.html"&gt;hopping off the bus, Gus&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Recommended usage: Go to the main page and continue hitting the 'prev' button until your boss/wife/parole officer starts asking questions.&lt;br /&gt;&lt;br /&gt;Many thanks to whichever Mac dev shared that site with me via their del.icio.us bookmarks. Sorry I don't remember who it was.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8093909139580325869-4362687134697992052?l=yamacdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamacdev.blogspot.com/feeds/4362687134697992052/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8093909139580325869&amp;postID=4362687134697992052' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/4362687134697992052'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/4362687134697992052'/><link rel='alternate' type='text/html' href='http://yamacdev.blogspot.com/2007/02/another-link-post.html' title='Another Link Post'/><author><name>Blake C.</name><uri>http://www.blogger.com/profile/08296013471634395562</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8093909139580325869.post-9030425473226917048</id><published>2007-02-20T21:47:00.000-08:00</published><updated>2007-11-30T18:12:21.411-08:00</updated><title type='text'>Some BOOLs Have All The Luck</title><content type='html'>&lt;b&gt;ALERT: This post has been proven wrong. It remains here as a badge of shame. Continue reading for entertainment purposes only!&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;A quick note, since something just bit me in the ass, and some of us dislike unsolicited ass-biting. Disclaimer: I'm using XCode 2.2 and whatever gdb was current then- this may have been fixed since then.&lt;br /&gt;&lt;br /&gt;I had a BOOL member/instance variable, we'll call it myBool. I set it like so-&lt;br /&gt;&lt;div class="source_code"&gt;myBool = someInt == someOtherInt;&lt;/div&gt;&lt;br /&gt;And all was well in both debug and release targets. Then I changed the scope of the member/instance variable to global, outside of any class, as in-&lt;br /&gt;&lt;br /&gt;&lt;pre class=".source_code"&gt;static BOOL myBool;&lt;/pre&gt;&lt;br /&gt;After doing so, the boolean expression above evaluated to false/NO, regardless of the values of the 2 ints. I watched it happen in XCode's debugger window, it was awesome.&lt;br /&gt;&lt;br /&gt;After several forceful introductions of my keyboard and my forehead, I tried a silly test that shouldn't matter at all, and it worked.&lt;br /&gt;&lt;br /&gt;&lt;pre class=".source_code"&gt;myBool = (someInt == someOtherInt);&lt;/pre&gt;&lt;br /&gt;I compiled and disassembled both versions of my release and debug targets, hoping for a most excellent blog post, and was greeted with identical code all round. So the problem appears to be that my version of gdb has different rules for evaluating boolean expressions, depending on the scope of the receiver of the expression. Global variables require a parenthesized expression while member/instance variables do not.&lt;br /&gt;&lt;br /&gt;One guess who will be parenthesizing more than usual in the future.&lt;br /&gt;&lt;br /&gt;And sorry, Wolf. The Rod Stewart reference was too good to pass up :)&lt;br /&gt;&lt;br /&gt;Update: &lt;a href="http://violasong.com/blog/"&gt;Victoria Wang&lt;/a&gt;, who I met at PSIG 101, posted an amusing quote about parentheses from one of her 'CIS' professors(Computing and Information Systems?)&lt;br /&gt;&lt;BLOCKQUOTE&gt;&lt;br /&gt;"Some teachers go crazy when you use parentheses on an expression that's going to be evaluated first anyway. I don't care. It's like wearing a belt, and suspenders too!"&lt;br /&gt;&lt;/BLOCKQUOTE&gt;&lt;br /&gt;So, did gdb swipe my belt or my suspenders? And can I set a watchpoint on my fly?&lt;br /&gt;&lt;br /&gt;Cheers, Victoria, and thanks to &lt;a href="http://rentzsch.com/"&gt;Wolf&lt;/a&gt; for the link.&lt;br /&gt;&lt;br /&gt;Update 2:&lt;br /&gt;After a restart, Xcode is no longer exhibiting the strange behavior. Maybe something was corrupt, I don't know. Sorry for the false alarm. It is now safe to reenter the building.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8093909139580325869-9030425473226917048?l=yamacdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamacdev.blogspot.com/feeds/9030425473226917048/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8093909139580325869&amp;postID=9030425473226917048' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/9030425473226917048'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/9030425473226917048'/><link rel='alternate' type='text/html' href='http://yamacdev.blogspot.com/2007/02/some-bools-have-all-luck.html' title='Some BOOLs Have All The Luck'/><author><name>Blake C.</name><uri>http://www.blogger.com/profile/08296013471634395562</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8093909139580325869.post-5218564609304765170</id><published>2007-02-14T19:14:00.000-08:00</published><updated>2007-02-14T19:22:50.015-08:00</updated><title type='text'>Show A Brotha Some Love</title><content type='html'>My boy Karsten just &lt;a href="http://briksoftware.com/blog/?p=24"&gt;pimped GDB&lt;/a&gt; and made copies of his &lt;a href="http://www.briksoftware.com/files/betterDebugger.zip"&gt;pimp cane&lt;/a&gt; available for all of us.&lt;br /&gt;&lt;br /&gt;Holla.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8093909139580325869-5218564609304765170?l=yamacdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamacdev.blogspot.com/feeds/5218564609304765170/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8093909139580325869&amp;postID=5218564609304765170' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/5218564609304765170'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/5218564609304765170'/><link rel='alternate' type='text/html' href='http://yamacdev.blogspot.com/2007/02/show-brotha-some-love.html' title='Show A Brotha Some Love'/><author><name>Blake C.</name><uri>http://www.blogger.com/profile/08296013471634395562</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8093909139580325869.post-6529009412182378216</id><published>2007-02-07T18:27:00.000-08:00</published><updated>2007-02-01T03:30:21.400-08:00</updated><title type='text'>God Went And Did It Again</title><content type='html'>Finally, &lt;a href="http://embeddedconservative.blogspot.com/2007/02/different-twist.html"&gt;the truth about global warming&lt;/a&gt;. Those damned scientists were really getting on my nerves.&lt;br /&gt;&lt;br /&gt;I don't want this to be a link blog, but this gem was too good to pass up.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8093909139580325869-6529009412182378216?l=yamacdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamacdev.blogspot.com/feeds/6529009412182378216/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8093909139580325869&amp;postID=6529009412182378216' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/6529009412182378216'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/6529009412182378216'/><link rel='alternate' type='text/html' href='http://yamacdev.blogspot.com/2007/02/god-went-and-did-it-again.html' title='God Went And Did It Again'/><author><name>Blake C.</name><uri>http://www.blogger.com/profile/08296013471634395562</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8093909139580325869.post-2186982399932544501</id><published>2007-01-30T20:52:00.000-08:00</published><updated>2007-01-30T20:57:00.985-08:00</updated><title type='text'>Free Noob Lesson</title><content type='html'>Unless you have an infinite stack and care not about results, don't call [someView display] inside [someView drawRect:].&lt;br /&gt;&lt;br /&gt;Bad dog. No bone.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8093909139580325869-2186982399932544501?l=yamacdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamacdev.blogspot.com/feeds/2186982399932544501/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8093909139580325869&amp;postID=2186982399932544501' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/2186982399932544501'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/2186982399932544501'/><link rel='alternate' type='text/html' href='http://yamacdev.blogspot.com/2007/01/free-noob-lesson.html' title='Free Noob Lesson'/><author><name>Blake C.</name><uri>http://www.blogger.com/profile/08296013471634395562</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8093909139580325869.post-8720174059888382298</id><published>2007-01-21T19:15:00.000-08:00</published><updated>2008-01-25T21:24:24.548-08:00</updated><title type='text'>CSS FTW</title><content type='html'>&lt;a href="http://mylargerscales.blogspot.com/"&gt;Kam Dahlin&lt;/a&gt; asked about my code formatting for the NSViewAnimation post, and I was embarassed to report that I had no special css style for it. So, my friend Mitch stepped up and handed me this:&lt;br /&gt;&lt;br /&gt;&lt;pre class=".source_code"&gt;.source_code, li .source_code {&lt;br /&gt; padding-left: 2px;&lt;br /&gt; border-left: 1px solid #666;&lt;br /&gt; font: 100% Monaco,monospace;&lt;br /&gt; font-size: 8pt;&lt;br /&gt; white-space: pre; /* CSS2 */&lt;br /&gt; white-space: -moz-pre-wrap; /* Mozilla */&lt;br /&gt; white-space: -hp-pre-wrap; /* HP printers */&lt;br /&gt; white-space: -o-pre-wrap; /* Opera 7 */&lt;br /&gt; white-space: -pre-wrap; /* Opera 4-6 */&lt;br /&gt; white-space: pre-wrap; /* CSS 2.1 */&lt;br /&gt; white-space: pre-line; /* CSS 3 (and 2.1 as well, actually) */&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/* change this line to set the width of box */&lt;br /&gt;&lt;br /&gt;.source_code {&lt;br /&gt; width: 100%;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/* change this line to set the width of box in a list */&lt;br /&gt;&lt;br /&gt;li .source_code {&lt;br /&gt; width: 100%;&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;strike&gt;Stick that in your css file, and invoke it by surrounding the code text with &amp;#60;div class="source_code"&amp;#62; and &amp;#60;/div&amp;#62;. You still have to detab the code first, but it beats the hell out of some &amp;amp;nbsp's. Also note that Blogger will not display the style when you preview a post- you have to submit the post to see it.&lt;/strike&gt;&lt;br /&gt;&lt;br /&gt;Update: Use "pre" instead of "div" and all is well.  I can fly through asm but html is a black art to me. Non-thanks to all who failed to correct me earlier :P&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8093909139580325869-8720174059888382298?l=yamacdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamacdev.blogspot.com/feeds/8720174059888382298/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8093909139580325869&amp;postID=8720174059888382298' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/8720174059888382298'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/8720174059888382298'/><link rel='alternate' type='text/html' href='http://yamacdev.blogspot.com/2007/01/css-ftw.html' title='CSS FTW'/><author><name>Blake C.</name><uri>http://www.blogger.com/profile/08296013471634395562</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8093909139580325869.post-3372633110530574396</id><published>2007-01-13T18:41:00.000-08:00</published><updated>2007-01-13T18:43:44.906-08:00</updated><title type='text'>a.out of gas</title><content type='html'>Gruber &lt;a href="http://daringfireball.net/linked/2007/january#fri-12-wes_felter"&gt;says&lt;/a&gt; it's not surprising that Apple has OS X compiling and running on something other than PPC or x86. Considering that &amp;#60mach/machine.h&amp;#62 lists 14 possible processor families, I have to agree with him. But what I find most interesting, assuming that the iPhone uses an ARM CPU, is that Apple is able to target one of the processors that is commented out in that file. If they're targeting ARM, maybe they're using 'gas' from binutils instead of 'as' from cctools...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8093909139580325869-3372633110530574396?l=yamacdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamacdev.blogspot.com/feeds/3372633110530574396/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8093909139580325869&amp;postID=3372633110530574396' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/3372633110530574396'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/3372633110530574396'/><link rel='alternate' type='text/html' href='http://yamacdev.blogspot.com/2007/01/aout-of-gas.html' title='a.out of gas'/><author><name>Blake C.</name><uri>http://www.blogger.com/profile/08296013471634395562</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8093909139580325869.post-5083301663606336865</id><published>2007-01-12T20:34:00.000-08:00</published><updated>2008-01-25T21:19:36.077-08:00</updated><title type='text'>Fun With Custom Keys</title><content type='html'>I was playing around with NSViewAnimation and I wondered why there weren't more predefined dictionary keys. Then I realized that it was just an associative array*, and I could define as many keys as I want, and take the appropriate action in a delegate method. This is probably obvious to most of you, but I just discovered it. So I gotta, you know, blog it.&lt;br /&gt;&lt;br /&gt;Here's an example I threw together that lets you swap one view for another after animatedly resizing a window. The most obvious use of this would be in a preference window, when switching between multiple tabs. For the example names, I'm using Wolf Rentzsch's 'NSX' &lt;a href="http://svn.sourceforge.net/viewvc/*checkout*/redshed/tags/NSXReturnThrowError-0.9/html/index.html"&gt;naming convention&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;pre class=".source_code"&gt;// Define custom objects and keys&lt;br /&gt;#define NSXViewAnimationSwapAtEndEffect @"NSXViewAnimationSwapAtEndEffect"&lt;br /&gt;#define NSXViewAnimationSwapOldKey      @"NSXViewAnimationSwapOldKey"&lt;br /&gt;#define NSXViewAnimationSwapNewKey      @"NSXViewAnimationSwapNewKey"&lt;/pre&gt;&lt;br /&gt;Then somewhere in your controller class:&lt;br /&gt;&lt;br /&gt;&lt;pre class=".source_code"&gt;    NSRect  newWindowFrame  = someCalculatedRect;&lt;br /&gt;&lt;br /&gt;    // Build a dictionary...&lt;br /&gt;    NSMutableDictionary*    windowDict =&lt;br /&gt;        [NSMutableDictionary dictionaryWithCapacity: 5];&lt;br /&gt;&lt;br /&gt;    // ...with standard keys...&lt;br /&gt;    [windowDict setObject: myWindow&lt;br /&gt;        forKey: NSViewAnimationTargetKey];&lt;br /&gt;    [windowDict setObject: [NSValue valueWithRect: newWindowFrame]&lt;br /&gt;        forKey: NSViewAnimationEndFrameKey];&lt;br /&gt;&lt;br /&gt;    // ...and custom keys.&lt;br /&gt;    [windowDict setObject: NSXViewAnimationSwapAtEndEffect&lt;br /&gt;        forKey: NSViewAnimationEffectKey];&lt;br /&gt;    [windowDict setObject: someViewToHide&lt;br /&gt;        forKey: NSXViewAnimationSwapOldKey];&lt;br /&gt;    [windowDict setObject: someViewToShow&lt;br /&gt;        forKey: NSXViewAnimationSwapNewKey];&lt;br /&gt;&lt;br /&gt;    // Create the animation.&lt;br /&gt;    NSViewAnimation*    windowAnim  = [[NSViewAnimation alloc]&lt;br /&gt;        initWithViewAnimations: [NSArray arrayWithObjects:&lt;br /&gt;        windowDict, nil]];&lt;br /&gt;&lt;br /&gt;    // Go.&lt;br /&gt;    [windowAnim setDelegate: self];&lt;br /&gt;    [windowAnim startAnimation];&lt;br /&gt;    [windowAnim autorelease];&lt;/pre&gt;&lt;br /&gt;And finally, the delegate method:&lt;br /&gt;&lt;br /&gt;&lt;pre class=".source_code"&gt;- (void)animationDidEnd: (NSAnimation*)animation&lt;br /&gt;{&lt;br /&gt;    // Standard sanity checks.&lt;br /&gt;    if (![animation isKindOfClass: [NSViewAnimation class]])&lt;br /&gt;        return;&lt;br /&gt;&lt;br /&gt;    NSArray*    animatedViews   =&lt;br /&gt;        [(NSViewAnimation*)animation viewAnimations];&lt;br /&gt;&lt;br /&gt;    if (!animatedViews)&lt;br /&gt;        return;&lt;br /&gt;&lt;br /&gt;    // Grab the window from the first animation.&lt;br /&gt;    NSWindow*   animatingWindow = [[animatedViews objectAtIndex: 0]&lt;br /&gt;        objectForKey: NSViewAnimationTargetKey];&lt;br /&gt;&lt;br /&gt;    if (animatingWindow != myWindow)&lt;br /&gt;        return;&lt;br /&gt;&lt;br /&gt;    // Iterate through possibly multiple animations.&lt;br /&gt;    UInt32  i;&lt;br /&gt;    UInt32  numAnimations   = [animatedViews count];&lt;br /&gt;    id      animObject      = nil;&lt;br /&gt;    id      keyObject       = nil;&lt;br /&gt;&lt;br /&gt;    for (i = 0; i &lt; numAnimations; i++)&lt;br /&gt;    {&lt;br /&gt;        animObject  = [animatedViews objectAtIndex: i];&lt;br /&gt;&lt;br /&gt;        if (!animObject)&lt;br /&gt;            continue;&lt;br /&gt;&lt;br /&gt;        // Grab our custom effect key.&lt;br /&gt;        keyObject   = [animObject objectForKey: NSViewAnimationEffectKey];&lt;br /&gt;&lt;br /&gt;        if (!keyObject)&lt;br /&gt;            continue;&lt;br /&gt;&lt;br /&gt;        // Execute the custom effect.&lt;br /&gt;        if ([keyObject isEqualToString: NSXViewAnimationSwapAtEndEffect])&lt;br /&gt;        {&lt;br /&gt;            NSView* oldView = [animObject&lt;br /&gt;                objectForKey: NSXViewAnimationSwapOldKey];&lt;br /&gt;            NSView* newView = [animObject&lt;br /&gt;                objectForKey: NSXViewAnimationSwapNewKey];&lt;br /&gt;&lt;br /&gt;            if (oldView)&lt;br /&gt;                [oldView setHidden: YES];&lt;br /&gt;&lt;br /&gt;            if (newView)&lt;br /&gt;                [newView setHidden: NO];&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;A trivial example, no doubt, but there are countless possibilities. Imagine calling setDuration: from the animation:didReachProgressMark: delegate to implement some crazy animation curve. Or overriding setCurrentProgress: in a subclass to link several animations more intuitively than with startWhenAnimation:reachesProgress:. Of course, all this is possible without using custom dictionary keys, but this way is a lot more fun.&lt;br /&gt;&lt;br /&gt;I'd love to hear any more uses you can think of, and other classes that use dictionaries in a similar way.&lt;br /&gt;&lt;br /&gt;*I originally said 'it was just xml', and Peter Hosey pointed out that while the key/object relationship evoked feelings of xml in me, it's not really xml until it's saved to disk. I've updated the text to more correctly describe data in memory.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8093909139580325869-5083301663606336865?l=yamacdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamacdev.blogspot.com/feeds/5083301663606336865/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8093909139580325869&amp;postID=5083301663606336865' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/5083301663606336865'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/5083301663606336865'/><link rel='alternate' type='text/html' href='http://yamacdev.blogspot.com/2007/01/fun-with-custom-keys.html' title='Fun With Custom Keys'/><author><name>Blake C.</name><uri>http://www.blogger.com/profile/08296013471634395562</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8093909139580325869.post-9081976444499398819</id><published>2007-01-10T20:55:00.000-08:00</published><updated>2007-01-10T21:24:11.804-08:00</updated><title type='text'>Score One For Curious George</title><content type='html'>My sources in Washington D.C. report that Dubya went to great lengths to schedule tonight's address. From planting moles inside Apple to buying iPods for all of the most influential journalists, no expense was spared. George's plan was executed without a hitch, and his most controversial address to date was carried out at exactly the perfect time.&lt;br /&gt;&lt;br /&gt;Here's what was going through his head while he read from the teleprompter:&lt;br /&gt;&lt;br /&gt;"I have decided to say 'Fuck You' to 65% of Americans, Gawd knows how many Iraqis, and whoever those guys are who did that report thingy. And probly Congress, too. Since you're all shitting yourselves about the iPhone, you're not even listening to me! Here it comes, bitches- iRock '07! Woohoo! No dictator? No WMDs? Who cares?! We got OS X on a phone!"&lt;br /&gt;&lt;br /&gt;Yeehaw, people. 20,000 iRock fans can't be wrong.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8093909139580325869-9081976444499398819?l=yamacdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamacdev.blogspot.com/feeds/9081976444499398819/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8093909139580325869&amp;postID=9081976444499398819' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/9081976444499398819'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/9081976444499398819'/><link rel='alternate' type='text/html' href='http://yamacdev.blogspot.com/2007/01/score-one-for-curious-george.html' title='Score One For Curious George'/><author><name>Blake C.</name><uri>http://www.blogger.com/profile/08296013471634395562</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8093909139580325869.post-118465684431473180</id><published>2007-01-05T19:23:00.000-08:00</published><updated>2007-01-22T22:51:36.934-08:00</updated><title type='text'>The Year of the HIG</title><content type='html'>Apparently, when &lt;a href="http://daringfireball.net/"&gt;Gruber&lt;/a&gt; speaks, people listen. "The HIG Is Dead", his presentation at C4, has sparked an incredible amount of discussion and activity recently. Amidst all the individual stories of developers sprucing up their UIs, Brandon Walkin has organized the &lt;a href="http://indiehig.com/blog/"&gt;Indie HIG&lt;/a&gt;. I highly recommend everyone take a look, and get involved if you like the idea. Also, I have an account there, and that makes it even cooler.&lt;br /&gt;&lt;br /&gt;It can't be expected to actually replace Apple's HIG, and Brandon says as much on the front page. It's largely a design principle popularity contest, with a bunch of dev types discussing do's and don'ts and occasionally agreeing with each other. And it will never have the authoritative feel of Apple's official docs. Having said all that, it's the best idea I've heard recently, and there's no way around those issues. Unless we can hypnotize Steve Jobs...&lt;br /&gt;&lt;br /&gt;Which brings me to another point- Apple's HIG 2.0. I predict this will be the year we see it. Not until WWDC, maybe, but I think Apple is paying attention. I believe the volume of public complaints from developers about the difficulty of maintaining a consistent look and feel has already surpassed Apple's threshold of tuning-out. There have been rumors of more standard controls in Leopard, and standard toolbar icons, etc. and the HIG 2.0 will be a perfect companion.&lt;br /&gt;&lt;br /&gt;In the meantime, join us over at the &lt;a href="http://indiehig.com/blog/"&gt;Indie HIG&lt;/a&gt;, and throw in your 2 cents. Imagine the stories you can tell your grandchildren when your ideas get rolled into the HIG 2.0...&lt;br /&gt;&lt;br /&gt;UPDATE&lt;br /&gt;My first-ever prediction may be comin' up Milhouse. Daniel Jalkut &lt;a href="http://www.red-sweater.com/blog/263/boston-leopard-tech-talk"&gt;gives me hope&lt;/a&gt;. And no, I did not attend the tech talk when it rolled through my town, which was before I posted my prediction.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8093909139580325869-118465684431473180?l=yamacdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamacdev.blogspot.com/feeds/118465684431473180/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8093909139580325869&amp;postID=118465684431473180' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/118465684431473180'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/118465684431473180'/><link rel='alternate' type='text/html' href='http://yamacdev.blogspot.com/2007/01/year-of-hig.html' title='The Year of the HIG'/><author><name>Blake C.</name><uri>http://www.blogger.com/profile/08296013471634395562</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8093909139580325869.post-5391502466728670237</id><published>2007-01-03T00:59:00.000-08:00</published><updated>2007-01-03T01:40:17.407-08:00</updated><title type='text'>Can't Touch Nibs</title><content type='html'>I heard something recently on the grapevine that I haven't yet seen in the blogosphere, so I thought I should mention it. If there's any demand, I'll dig deeper into the code and post further details.&lt;br /&gt;&lt;br /&gt;- Open up Interface Builder, create and save a new blank nib file(Cocoa/Application).&lt;br /&gt;- Locate the new nib in Finder, and 'Show Package Contents'.&lt;br /&gt;- Delete 'classes.nib' and 'info.nib', but leave 'keyedobjects.nib'.&lt;br /&gt;- Attempt to reopen the modified nib package in IB.&lt;br /&gt;- Marvel at IB's reluctance to open the file for editing.&lt;br /&gt;&lt;br /&gt;Ok, so IB won't open it, so what?&lt;br /&gt;&lt;br /&gt;It turns out that IB's 'Open' command and [NSBundle loadNibNamed:owner:] have entirely different requirements regarding the contents of the nib package we're attempting to load/open.&lt;br /&gt;&lt;br /&gt;The reason this came to light was that someone was trying to have a look at XCode 2.4.x nibs, which lack the 2 files we deleted above. I'm not sure when Apple started deleting those 2 files, but on my box(XCode 2.2) I have all 3 internal files in 'PBX.nib' and 'PBXActiveOperationsPanel.nib'. But obviously, since XCode 2.4.x launches with no errors, those 2 deleted files aren't needed at runtime.&lt;br /&gt;&lt;br /&gt;So, at first glance, the moral of the story is- you can keep your users from opening your nibs in IB(thus keeping those damned GUI hackers at bay) by simply deleting the aforementioned files from your nibs, possibly with a custom build phase.&lt;br /&gt;&lt;br /&gt;But just for fun, we glanced twice.&lt;br /&gt;&lt;br /&gt;- Repeat the 'create and save a blank nib file' steps, but this time, don't delete anything.&lt;br /&gt;- Copy 'classes.nib' and 'info.nib' from the newly created nib package into the unopenable nib package.&lt;br /&gt;- Marvel at IB's willingness to open the previously unopenable file for editing.&lt;br /&gt;&lt;br /&gt;I am sure that there is some information lost in the translation, but this seems to be a good start. As always, any comments/questions/suggestions are welcome.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8093909139580325869-5391502466728670237?l=yamacdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamacdev.blogspot.com/feeds/5391502466728670237/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8093909139580325869&amp;postID=5391502466728670237' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/5391502466728670237'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/5391502466728670237'/><link rel='alternate' type='text/html' href='http://yamacdev.blogspot.com/2007/01/cant-touch-nibs.html' title='Can&apos;t Touch Nibs'/><author><name>Blake C.</name><uri>http://www.blogger.com/profile/08296013471634395562</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8093909139580325869.post-4899744874519380579</id><published>2006-12-24T18:36:00.000-08:00</published><updated>2006-12-24T19:14:03.176-08:00</updated><title type='text'>Checksum, Please</title><content type='html'>I was playing around with file comparisons recently, and I thought I could have some fun with crc32(). It's a common function, so it's probably in the system somewhere already. I asked man about it and there it is, in the 'n' section of the man pages:&lt;br /&gt;&lt;br /&gt;DESCRIPTION&lt;br /&gt;       This package provides a Tcl-only implementation of the CRC-32 algorithm based  upon   information   provided   at   http://www.naaccr.org/standard/crc32/document.html  If the Trf package is available then the crc-zlib command is used to perform the calculation.&lt;br /&gt;&lt;br /&gt;Tcl-only, great. And searching the XCode docs just lead to the same man page. But I couldn't believe there's not a C function in the system somewhere, so I asked google to have a look at the Darwin source, and found &lt;a href="http://www.opensource.apple.com/darwinsource/Current/gcc_os-1819/zlib/crc32.c"&gt;this page&lt;/a&gt;. Ah, it's part of zlib, as mentioned in the man page description. No wonder Apple has no docs describing it.&lt;br /&gt;&lt;br /&gt;So next time you need a 32-bit checksum, add -lz to your linker flags and send me a postcard.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8093909139580325869-4899744874519380579?l=yamacdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamacdev.blogspot.com/feeds/4899744874519380579/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8093909139580325869&amp;postID=4899744874519380579' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/4899744874519380579'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/4899744874519380579'/><link rel='alternate' type='text/html' href='http://yamacdev.blogspot.com/2006/12/checksum-please.html' title='Checksum, Please'/><author><name>Blake C.</name><uri>http://www.blogger.com/profile/08296013471634395562</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8093909139580325869.post-8549856222886217409</id><published>2006-12-22T17:11:00.000-08:00</published><updated>2006-12-22T17:20:16.319-08:00</updated><title type='text'>MacMob</title><content type='html'>I propose a new Mac software promotion.&lt;br /&gt;&lt;br /&gt;For the next few days, participating developers will set aside 20% of their profits and pool the cash. Using the cash, we will procure an assortment of small arms and blunt objects, and hire a P.I. to find &lt;a href="http://weblog.bignerdranch.com/?p=21"&gt;the jackass who shat on Aaron's holidays&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8093909139580325869-8549856222886217409?l=yamacdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamacdev.blogspot.com/feeds/8549856222886217409/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8093909139580325869&amp;postID=8549856222886217409' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/8549856222886217409'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/8549856222886217409'/><link rel='alternate' type='text/html' href='http://yamacdev.blogspot.com/2006/12/macmob.html' title='MacMob'/><author><name>Blake C.</name><uri>http://www.blogger.com/profile/08296013471634395562</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8093909139580325869.post-7865790109691693777</id><published>2006-12-18T21:05:00.000-08:00</published><updated>2006-12-18T21:09:49.851-08:00</updated><title type='text'>Of Balls and Whiners</title><content type='html'>I've never been paid to write code, so I'm ill-qualified to form an opinion on the whole MacHeist thing. I do however have a keen eye for idiocy, and one group in particular seems in need of calling-out. To paraphrase:&lt;br /&gt;&lt;br /&gt;"Screw you, Gus! You just lost a potential and/or current customer!"&lt;br /&gt;&lt;br /&gt;What? Let's try to understand the reasoning behind such a statement, starting with the most illogical.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Possibility the First:&lt;/b&gt;&lt;br /&gt;These people actually think there is some correlation between a developer's opinions or attitude and his products. It could happen I guess. If a developer can maintain a list of pirated serial numbers, and make their app not work with them, it stands to reason that they could just as easily maintain a list of apps that have been included in the MacHeist bundle, and make their apps not work when those other apps are installed. And if the developer has balls enough to speak his mind without trying to kiss anyone's ass, he's certainly capable of making his app trash your whole system! Therefore, as cautious consumers and MacHeist fans, we would all do well to avoid apps from that developer.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Possibility the Second:&lt;/b&gt;&lt;br /&gt;These people actually think that the revenue lost by their secession will have an impact great enough to make a developer see the error of his ways. That sounds reasonable, maybe. Assuming Flying Meat has fewer than ten paying customers, that's a sizeable chunk of income to lose.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Possibility the Third:&lt;/b&gt;&lt;br /&gt;These people actually think that although a single user's threat would have little impact, a concerted effort by many organized users will have the desired effect. So, if we all band together and sign the petition, we can force him to change his ways.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Possibility the Fourth:&lt;/b&gt;&lt;br /&gt;These people subconsciously realize that they're bringing nothing to the table and feel embarrassed to burden Gus any longer with all their support issues. The only sensible thing to do is to remove themselves from the picture in a flaming puff of glory.&lt;br /&gt;&lt;br /&gt;It never occurred to me before all this, but now I'm wondering: When I'm shopping for software, how much do I care about the developer's personal life? Say the guy sacrifices goats and small children on weekends. Can he write code that makes me do that? No? Ok, then, yea I'll buy his apps. On the other hand, say he keeps his mouth shut when he takes issue with something, to avoid possibly stepping on anyone's toes. I wouldn't respect him quite as much, but I'd still buy his apps.&lt;br /&gt;&lt;br /&gt;I guess I shouldn't complain, really. All of the informed opinions on both sides of the issue have given me things to think about that otherwise wouldn't have occurred to me. And the whiners balanced it out with some much needed comedy.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8093909139580325869-7865790109691693777?l=yamacdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamacdev.blogspot.com/feeds/7865790109691693777/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8093909139580325869&amp;postID=7865790109691693777' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/7865790109691693777'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/7865790109691693777'/><link rel='alternate' type='text/html' href='http://yamacdev.blogspot.com/2006/12/of-balls-and-whiners.html' title='Of Balls and Whiners'/><author><name>Blake C.</name><uri>http://www.blogger.com/profile/08296013471634395562</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8093909139580325869.post-1411774469915893896</id><published>2006-12-17T22:46:00.001-08:00</published><updated>2008-01-25T21:28:15.953-08:00</updated><title type='text'>Implicit memcpy(3) calls</title><content type='html'>Peter Hosey was kind enough to &lt;a href="http://boredzo.org/blog/archives/2006-11-26/calloc-vs-malloc"&gt;document&lt;/a&gt; the speed difference between malloc() followed by bzero() and calloc(). They are two different ways to allocate and zero a block of memory, but it turns out that calloc() is much faster.&lt;br /&gt;&lt;br /&gt;I was wondering how much of that speed difference is the result of having one fewer function call in your code, and that reminded me of a lesson I learned a few months ago...&lt;br /&gt;&lt;br /&gt;Some time ago, I picked up the practice of initializing all local variables at their declarations, like:&lt;br /&gt;&lt;pre class=".source_code"&gt;&lt;br /&gt;double aDouble = 0.0;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;In many cases, it's not really necessary, and the coders who disagreed with the practice correctly pointed out that I was simply adding extra code and extending the execution time. My reasoning was that not having garbage data in a local variable is worth the extra few cycles it takes to zero an integer or even a double.&lt;br /&gt;&lt;br /&gt;At the time, I was a PowerPlant junkie, and would initialize LStrings with Str_Empty or whatever it was called. And all was good.&lt;br /&gt;&lt;br /&gt;Since I've switched to XCode, I've been using C strings more than ever before. NSMutableString is great when it's possible to use it, but creating, modifying and releasing a few hundred million of them gets annoying. So I was using lots of C strings and initializing them to zeroed bytes like so:&lt;br /&gt;&lt;pre class=".source_code"&gt;&lt;br /&gt;char aString[1000] = {0};&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;I knew that only the first byte needed to be zero to qualify the local variable as a null string, but I didn't like garbage data. In addition, if any of my subsequent string handling code accidentally left out the null terminator, it would still be there. It was a win/win situation, and it worked flawlessly.&lt;br /&gt;&lt;br /&gt;As it turned out, my adoption of the initialize-blindly-at-declaration practice slowed things down considerably when dealing with C strings. After optimizing all I could, Shark told me that about 55% of my code's running time was spent in memcpy(). At first I thought that was a good sign. After all, I was not calling memcpy() explicitly in my code, so it must have been invoked by printf, scanf, and the like. And I figured that when more than half the time is spent in low level system functions, I've done all I can.&lt;br /&gt;&lt;br /&gt;Out of curiosity, I disassembled the app I was working on with otool and searched for "memcpy". Holy shit, it's everywhere. It's not only being invoked from printf/scanf(which Shark would have told me if I had asked). This is when the lesson sunk in- zeroing an entire C string of arbitrary length is a Bad Idea™. gcc translated my harmless {0} into a memcpy call. Combine that with 10 or 20 C strings per method, with each method being called a few million times, and I began to see why memcpy was the latest culprit according to Shark. Although I was not calling memcpy() explicitly, gcc was. A lot.&lt;br /&gt;&lt;br /&gt;So I still initalize atomic variables in their declarations, but I'm much more careful when using composite data types. Before typing this post I just used my instinct to decide which way to go. But since Peter was generous enough to provide some empirical data, I may as well follow suit.&lt;br /&gt;&lt;br /&gt;Not surprisingly, PowerPC and Intel code behave quite differently. Here's what I found when using the initialize-at-declaration approach for C strings. The following disassembly is modified output from &lt;a href="http://otx.osxninja.com/"&gt;otx&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;PowerPC&lt;/b&gt;&lt;br /&gt;If the char array is less than or equal to 32 bytes, gcc produces inline load/store instructions. For example, a 16 byte string:&lt;br /&gt;&lt;pre class=".source_code"&gt;&lt;br /&gt;3c400004&amp;nbsp;&amp;nbsp;lis&amp;nbsp;&amp;nbsp;&amp;nbsp;r2,0x4&lt;br /&gt;3842ef54&amp;nbsp;&amp;nbsp;addi&amp;nbsp;&amp;nbsp;r2,r2,0xef54&lt;br /&gt;80020000&amp;nbsp;&amp;nbsp;lwz&amp;nbsp;&amp;nbsp;&amp;nbsp;r0,0x0(r2)&lt;br /&gt;81220004&amp;nbsp;&amp;nbsp;lwz&amp;nbsp;&amp;nbsp;&amp;nbsp;r9,0x4(r2)&lt;br /&gt;81620008&amp;nbsp;&amp;nbsp;lwz&amp;nbsp;&amp;nbsp;&amp;nbsp;r11,0x8(r2)&lt;br /&gt;8042000c&amp;nbsp;&amp;nbsp;lwz&amp;nbsp;&amp;nbsp;&amp;nbsp;r2,0xc(r2)&lt;br /&gt;901e0018&amp;nbsp;&amp;nbsp;stw&amp;nbsp;&amp;nbsp;&amp;nbsp;r0,0x18(r30)&lt;br /&gt;913e001c&amp;nbsp;&amp;nbsp;stw&amp;nbsp;&amp;nbsp;&amp;nbsp;r9,0x1c(r30)&lt;br /&gt;917e0020&amp;nbsp;&amp;nbsp;stw&amp;nbsp;&amp;nbsp;&amp;nbsp;r11,0x20(r30)&lt;br /&gt;905e0024&amp;nbsp;&amp;nbsp;stw&amp;nbsp;&amp;nbsp;&amp;nbsp;r2,0x24(r30)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;where the data pointed to by 0x3ef54 is a bunch of zeroes, and r30 is a copy of the stack pointer.&lt;br /&gt;&lt;br /&gt;If the char array is greater than 32 bytes, gcc inserts a call to memcpy().&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Intel&lt;/b&gt;&lt;br /&gt;If the char array is less than or equal to 64 bytes, gcc produces inline move instructions. For example, the same 16 byte string:&lt;br /&gt;&lt;pre class=".source_code"&gt;&lt;br /&gt;c745e800000000&amp;nbsp;&amp;nbsp;movl&amp;nbsp;&amp;nbsp;$0x00000000,0xffffffe8(%ebp)&lt;br /&gt;c745ec00000000&amp;nbsp;&amp;nbsp;movl&amp;nbsp;&amp;nbsp;$0x00000000,0xffffffec(%ebp)&lt;br /&gt;c745f000000000&amp;nbsp;&amp;nbsp;movl&amp;nbsp&amp;nbsp;$0x00000000,0xfffffff0(%ebp)&lt;br /&gt;c745f400000000&amp;nbsp;&amp;nbsp;movl&amp;nbsp;&amp;nbsp;$0x00000000,0xfffffff4(%ebp)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;If the char array is greater than 64 bytes, gcc inserts a call to either memset() or memcpy().&lt;br /&gt;&lt;br /&gt;So apparently, if the length of your C string is more than 16 times the number of bytes your CPU can zero with a single instruction, gcc will insert a call to memcpy(). Moral of the story- only zero the first byte of a C string, unless it's absolutely necessary, or speed doesn't matter.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8093909139580325869-1411774469915893896?l=yamacdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamacdev.blogspot.com/feeds/1411774469915893896/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8093909139580325869&amp;postID=1411774469915893896' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/1411774469915893896'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/1411774469915893896'/><link rel='alternate' type='text/html' href='http://yamacdev.blogspot.com/2006/12/implicit-memcpy3-calls.html' title='Implicit memcpy(3) calls'/><author><name>Blake C.</name><uri>http://www.blogger.com/profile/08296013471634395562</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8093909139580325869.post-4773545203661061701</id><published>2006-12-16T15:23:00.000-08:00</published><updated>2006-12-16T22:54:20.290-08:00</updated><title type='text'>Belated C4 words</title><content type='html'>0xC4 == 196, which is roughly the number of Mac laptops I saw there. I gotta get me one of those. Jokes aside, there were actually 98 attendees, which seems somehow related to 196...&lt;br /&gt;&lt;br /&gt;Summaries of the presentations have been posted all over, so I'll just relay my personal experiences. One thing that I noticed was how accessible everyone was. Nobody cared that I don't have any apps out there, or that I asked a lot of stupid questions. A good example would be &lt;a href="http://rentzsch.com"&gt;Wolf Rentzsch&lt;/a&gt;. Here's a successful consultant type who's forgotten more than I've learned, and is still totally easy to talk to. I hope I'm that nice when I'm rich and famous. Thanks again, Wolf, for the whole show!&lt;br /&gt;&lt;br /&gt;Bob Frank is another good example. Snakebite himself. I chatted with him several times, but he's more into Java, so we didn't have a lot in common. Still, he was more than happy to answer stupid questions.&lt;br /&gt;&lt;br /&gt;I also got to chat a bit with &lt;a href="http://www.gusmueller.com/blog/"&gt;Gus Mueller&lt;/a&gt;. I had to raise my voice a little because he's approximately 8 feet tall. I think the people insulting him on his blog lately don't know just how big this guy is. Seriously, don't mess with Gus. Nice guy though, and it must have been a good feeling to see at least half of the presenters using VoodooPad.&lt;br /&gt;&lt;br /&gt;Speaking of tall, I met &lt;a href="http://weblog.bignerdranch.com/"&gt;Aaron Hillegass&lt;/a&gt;. WTF! I was looking up at him even when he was on the other side of the room. Another nice guy. I had fun telling him all about how I hadn't read any of his books, and never heard of the ranch and boot camp, etc.&lt;br /&gt;&lt;br /&gt;Actually, that was a recurring theme for me. Hopefully by next year I'll have more experience with some of the awesome apps these guys write. One app that caught my eye was &lt;a href="http://www.knoxformac.com/"&gt;Knox&lt;/a&gt;. &lt;a href="http://www.markokarppinen.com/"&gt;Marko Karppinen&lt;/a&gt; was sitting at my table on day 2, and he showed me all the cool stuff it does. If you need encrypted disk images, give it a shot.&lt;br /&gt;&lt;br /&gt;Another guy at my table was &lt;a href="http://apparentmotion.com/thoughts/index.php"&gt;Travis Cripps&lt;/a&gt;. They say you gotta watch out for the quiet types, and that's him. He knows his stuff, keep an eye out for his apps.&lt;br /&gt;&lt;br /&gt;I talked quite a bit with Chris Patterson. Sadly, Chris is currently writing non-Mac code. We met up with one of his coworkers, Daron something, at Jak's Tap after day 1. That was awesome, because we're all former PowerPlant geeks. Beer, multiple inheritance, stack based classes, beer, polymorphism, RTTI, beer. The chicks were diggin it.&lt;br /&gt;&lt;br /&gt;That reminds me of the only thing I regret about C4. On day 2 there was a guy sitting behind me who spoke up after every single presentation. Normally I wouldn't have remembered him, but the thing is- he didn't ask a single question. It was always some comment or suggestion or polite disagreement. I kept wondering who this guy was, who seemed to know just as much or more about every presenter's topic. So I glanced at his name tag and googled him after it was all over: Ben Artin...&lt;br /&gt;&lt;br /&gt;Hey, that's funny- his pgp key is right next to meeroh's key on the keyserver. I haven't heard from meeroh in a long time. If you've written more than 3 lines of PowerPlant code, you probably remember meeroh from comp.sys.mac.oop.powerplant. Most of the questions I had over the years were answered by him, sometimes in a previous post, sometimes my own. That dude was smart as hell, wouldn't it be great to meet him...&lt;br /&gt;&lt;br /&gt;Oh, look- meeroh changed his name to Ben Artin.&lt;br /&gt;&lt;br /&gt;Dammit! That was meeroh! 10 feet away from me all day. No wonder he seemed to know so much. He did.&lt;br /&gt;&lt;br /&gt;So, I didn't meet meeroh/Ben. Maybe next time. But I did talk to lots of excellent coders, and had a blast. Quick shouts to &lt;a href="http://www.rogueamoeba.com/utm/"&gt;Paul Kafasis&lt;/a&gt;, &lt;a href="http://daringfireball.net/"&gt;John Gruber&lt;/a&gt;, &lt;a href="http://iolanguage.com/"&gt;Steve Dekorte&lt;/a&gt;, &lt;a href="http://drunkenblog.com/"&gt;DB&lt;/a&gt;, &lt;a href="http://www.red-sweater.com/blog/"&gt;Daniel Jalkut&lt;/a&gt;, &lt;a href="http://inessential.com/"&gt;Brent Simmons&lt;/a&gt;, and Ed, Mike and Kevin from Apple. Hopefully I'll see all of you again next year...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8093909139580325869-4773545203661061701?l=yamacdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamacdev.blogspot.com/feeds/4773545203661061701/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8093909139580325869&amp;postID=4773545203661061701' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/4773545203661061701'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/4773545203661061701'/><link rel='alternate' type='text/html' href='http://yamacdev.blogspot.com/2006/12/belated-c4-words.html' title='Belated C4 words'/><author><name>Blake C.</name><uri>http://www.blogger.com/profile/08296013471634395562</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8093909139580325869.post-4100212331444540048</id><published>2006-12-15T20:07:00.000-08:00</published><updated>2006-12-15T20:38:01.000-08:00</updated><title type='text'>numMacDevBlogs++;</title><content type='html'>Welcome, all, to YAMDB. I write Mac code and I have opinions, so it's only fitting that I should have a blog. Also, &lt;a href="http://red-sweater.com/blog"&gt;Daniel Jalkut&lt;/a&gt; told me to start one, and I don't want to disappoint.&lt;br /&gt;&lt;br /&gt;I've been writing Mac code for about 8 years, and only recently took the Obj-C/Cocoa plunge. So far, no regrets other than the message dispatch overhead(flame at will). It does seem curious, though, how "Mac development" seems to be synonymous with "Cocoa development" these days. Maybe it's just me, but now that I have a reason to learn Unix, I find the underlying system equally as fascinating as Apple's latest API. Before the flames engulf me- I am not insulting Cocoa, and I am enjoying learning more about Cocoa every day from all the other Mac devs. It's simply easier for me to learn the Unix stuff, with good ole C.&lt;br /&gt;&lt;br /&gt;With that in mind, I hope to balance out the Cocoa-heavy blogosphere with a bit of the old-fashioned, procedural Unix goodness. I reserve the right to also post Cocoa stuff occasionally.&lt;br /&gt;&lt;br /&gt;I also hope to keep things purely technical and avoid politics. Given the current climate of MacHeist, phantom exploits, and general Wintards, we'll see how that pans out.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8093909139580325869-4100212331444540048?l=yamacdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://yamacdev.blogspot.com/feeds/4100212331444540048/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8093909139580325869&amp;postID=4100212331444540048' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/4100212331444540048'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8093909139580325869/posts/default/4100212331444540048'/><link rel='alternate' type='text/html' href='http://yamacdev.blogspot.com/2006/12/nummacdevblogs.html' title='numMacDevBlogs++;'/><author><name>Blake C.</name><uri>http://www.blogger.com/profile/08296013471634395562</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
