Why isn't the NULL-check needed? free(NULL) has an undefinied behavior...
/Fredrik
Post by 123 One patch for README, one for dFree (no need to check for NULL) and one for sizeof usage. _______________________________________________ Dillo-dev mailing list http://lists.auriga.wearlab.de/cgi-bin/mailman/listinfo/dillo-dev
Post by Fredrik Gustafsson Why isn't the NULL-check needed? free(NULL) has an undefinied behavior... /Fredrik
Post by 123 One patch for README, one for dFree (no need to check for NULL) and one for sizeof usage. _______________________________________________ Dillo-dev mailing list http://lists.auriga.wearlab.de/cgi-bin/mailman/listinfo/dillo-dev
Post by 123 One patch for README, one for dFree (no need to check for NULL) and one for sizeof usage.
thanks, committed.
BTW, why is it better to have sizeof this way? - (sizeof(Css_shorthand_info) / sizeof(CssShorthandInfo)) + (sizeof(Css_shorthand_info) / sizeof(Css_shorthand_info[0]))
This way it stays correct even if someone changes the type of Css_shorthand_info to say CssShorthandInfo2. Not a big improvement, but I like it being consistently done like that.
Post by Alexander Voigt Hi 123, why not introducing a macro like #define LENGTH(X) (sizeof (X) / sizeof (X)[0]) which could be used in all these for loops? I think this would make the code simpler and less error prone.
I'm not a fan of hiding this in macros. Something like
struct foo * f = malloc(sizeof(struct foo) * 10); for(int i = 0; i < LENGTH(f); i++) {
looks even more unsuspicious than with the sizeof stuff visible.