Please sign in to comment.
Defensive programming leads to sloppy programming
Given the functions changed: gnugol_init_QueryOptions() gnugol_reset_QueryOptions() gnugol_free_QueryOptions() when will you *ever* pass a NULL QueryOptions_t to it? You won't, unless it's a programming mistake, but in checking for NULL and doing stuff if it isn't hides bugs. One tenent of programming I do: THOU SHALT GIVE VALID PARAMETERS TO A FUNCTION (and in return, they'll return valid data) So, with that in mind, get rid of the unnecessary checks for NULL (remember: you won't be passing in NULL, now will you?) Also, free() accepts a NULL (it won't do anything) so there's no need to check for that condition. And besides, those pointers won't be NULL anyway, right? Right. If this gives you the heebie-jeebies, you haven't programmed enough with this style. It really does make for rock solid code. But you do need to learn to live with assert().
- Loading branch information...