« Lord of the Beans | Home | Spaniards and Number Theory »

Work Frustration

Monday, December 5, 2005

I have been working on an extremely frustrating project for the past several months. I won't provide a complete picture since this is a public site and all, but here is a glimpse of what it has been like.

Every few days I come across something like this:
hold = dataPtr[3];
dataPtr[0] = dataPtr[3];
dataPtr[1] = dataPtr[2];
dataPtr[2] = dataPtr[1];
dataPtr[3] = hold;

I found this gem today. The guy who wrote this was trying to swap the byte ordering of a 32-bit variable. I should also note that he used this snippet of code over forty times (functions or macros...nah).

Comments

what's your point? i find this code absolutely sublime. and, the algorithm runs in O(n) time. pretty darn fast.

have you considered that, since he used it over 40 times, that he intended the logic to be precisely the way it was written? i mean, are you sure that he was trying to swap the bytes? perhaps it was code to deliberately misguide would-be malicious adversaries. huh? huh?

code monkeys unite!

Posted by: code monkey on Monday, December 5, 2005

It's a good thing he used that temporary variable hold. Otherwise he might have accidentally overwritten the data before he had a chance to read it.

Posted by: Jeremy Stein on Tuesday, December 6, 2005

Post a comment




Remember Me?

(you may use HTML tags for style)

Comment Preview

Posted by: