Discussion:
cleanup patches
123
2012-05-26 11:02:24 UTC
Permalink
One patch for README, one for dFree (no need to check for NULL) and
one for sizeof usage.
Fredrik Gustafsson
2012-05-26 11:40:19 UTC
Permalink
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
Fredrik Gustafsson
2012-05-26 11:41:33 UTC
Permalink
Sry, my bad. Never mind
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
Johannes Hofmann
2012-05-26 12:02:17 UTC
Permalink
Post by 123
One patch for README, one for dFree (no need to check for NULL) and
one for sizeof usage.
thanks, committed.

Cheers,
Johannes
Jorge Arellano Cid
2012-05-26 13:26:39 UTC
Permalink
Post by Johannes Hofmann
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]))
--
Cheers
Jorge.-
Johannes Hofmann
2012-05-26 13:41:40 UTC
Permalink
Post by Jorge Arellano Cid
Post by Johannes Hofmann
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.

Cheers,
Johannes
Alexander Voigt
2012-05-26 13:59:12 UTC
Permalink
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.

Best,
Alexander
Johannes Hofmann
2012-05-26 14:24:32 UTC
Permalink
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.

Cheers,
Johannes

Loading...