Levi Broderick sent in an entertaining story a while ago that has been patiently waiting to be shared. And what better than the 1AM post to accomplish this? 

In the Spring of 2003, I was attending Carnegie Mellon and enrolled in an introductory C class.  One of our homework assignments was to implement a linked list.  Such an implementation had to include a function that took as an argument a pointer to the head node, freed all the memory associated with the linked list, and returned nothing.

Anyway, when we had done this assignment and turned it in, our TA sent us a message that included a code snippet:

void FreeThisSchnizzle(void* head)
{
  free((void*) head);
  FreeThisSchnizzle(head->next);
}

Evidently one of the students in the class had turned this in, and the TA responded accordingly.  (I have to paraphrase here, as I don't have the original message)

"Guys, please test your code before you submit it to us.  The function to free your linked list is worth 20% of your grade on this assignment, so don't mess it up!"

At any rate, the kid never resubmitted the code to the TA, so he was docked 20 of 100 points in the following manner:

  • -1 for not checking if the pointer is null and for calling free() before recursing.
  • -1 for calling this function FreeThisSchnizzle()
  • -18 for sucking at life

Now who had a guy like this in your class ... or who was this guy in your class? 

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!