Subject: Re: Proposal to include a game to the system (2nd part)
To: None <ilfoglionascosto@netcat.it, netbsd-users@NetBSD.org>
From: John Nemeth <jnemeth@victoria.tc.ca>
List: netbsd-users
Date: 07/02/2006 02:43:02
On Nov 21, 10:56pm, "Claudio M." wrote:
} 
}    i've posted few weeks ago about including a little curses-based game
}    to the system. Unlucky i did some problem with my mail system
}    so i did can't reply to your posts. Really i have problems
}    to reply on the MLs yet :-)
} 
}    First of all, THX to Martin Husemann for its suggest: i have included

     Just a little nitpick.  This should say, "his support."  "its"
would be used when you are referring to a thing.

}    the auto-mode (or demo mode) which allow the game to play without user
}    interaction (as a console-based screensaver).
}    Second i've switched from GPL to the BSD license. This because i would

     The third claus of the licence should refer to you, not the
"University", since this game has nothing to do with any university.
Also, the software is not provided by the "REGENTS", it is provided by
you.

}    really include that game to the system and a GPLed software, as far as
}    i have understood, can't be included. I'm forgetting something? :-)

    GPLed software does make it into the system when really necessary,
but we do try to discourage it.

}    The updated version can be found here:
}       http://dinotte.altervista.org/files/worm2.1.c

     I took a really quick look.  A couple of things I noticed.  The
program style should follow the style guide, which can found in
/usr/share/misc/style.  Also, at the end of the file, I noticed this
function:

/*
 * Kill the worm: free the whole worm's memory
*/
void killworm(List **worm)
{
   List *current = *worm;

   while( ((*worm) = current) != NULL ) {
      free( current );
      current = current->next;
   }

} /* eof killworm() */

Notice that you are using current after you free it.  This is a very
bad thing.  On some systems, this would cause the program to crash.
The function should be written like this (some of the changes are to
satisfy the style guide):

/*
 * Kill the worm: free the whole worm's memory
 */
void killworm(List **worm)
{
	List *current;

	while (*worm != NULL) {
		current = *worm;
		*worm = (*worm)->next;
		free(current);
	}
}

Note that I did not do a complete audit of the program, this is just
something that caught my eye.  Also, I haven't tested my rewrite.
Although, I believe it to be bug free, I will not guarantee it.  Just
my own discliamer.  :-)

}-- End of excerpt from "Claudio M."