On Thu, 28.11.13 09:32, David Herrmann (dh.herrm...@gmail.com) wrote: > >> + sd_gfx_font *font; > >> + int r; > >> + > >> + ppi = CLAMP(ppi, 10U, 1000U); > >> + > >> + font = calloc(1, sizeof(*font)); > > > > font = new0(sd_gfx_font, 1); > > I actually dislike new0() to require the type. I'd prefer: > font = new0(font); > But this is horrible to read, so I went with calloc(1, sizeof(*xyz)); > But the systemd code-base seems to use new0() consistently so I can > adjust all my calloc()s if you want? I'm fine with keeping consistency > here.
I'd really prefer that. Not that new() is a glibc thing, where they have g_new(). Of all the type-safe macros for allocation I certainly like it the best... > > For public APIs we are pretty defensive and check all parameters we > > take. Given you kinda made this a public library it might make sense to > > follow that rule here, too. assert_return() is particularly useful for > > this. (Well, not for the instance above, bug if you return a negative > > errno it is super-useful). > > I wanna avoid these in fast-paths (the blending/blitting functions) > but for all the other ones, I can add assert()s. Yes, please do not add assert()s in inner loops! I mean, the whole assert() story is not that definitive either. I add them to a lot of functions, but I can totally understand when people think I am adding to many of them.... Lennart -- Lennart Poettering, Red Hat _______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel