On Wed, 16.01.13 00:17, Jan Engelhardt ([email protected]) wrote:

> On Tuesday 2013-01-15 20:47, Lennart Poettering wrote:
> >> --- a/src/bootchart/bootchart.c
> >> +++ b/src/bootchart/bootchart.c
> >> @@ -232,12 +232,11 @@ int main(int argc, char *argv[])
> >>          }
> >>  
> >>          /* start with empty ps LL */
> >> -        ps_first = malloc(sizeof(struct ps_struct));
> >> +        ps_first = calloc(1, sizeof(struct ps_struct));
> >
> >BTW, we have a nice macro for this: 
> >
> >     ps_first = new0(struct ps_struct, 1);
> >
> >It's tape-safe and a bit nicer to read.
> 
> If tape-safety was that important, one would do away with tapes
> altogether and use sizeof with like ps_first = calloc(1, sizeof(*ps_first))

Well, that would infer the type from the variable. The new0() code above
otoh includes the extra sanity check that the variable we assign the
object we allocate to is actually of the right type to accept the object
we are allocating.

Lennart

-- 
Lennart Poettering - Red Hat, Inc.
_______________________________________________
systemd-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to