[systemd-devel] [PATCH 3/3] bootchart: Convert malloc/memset to calloc.

Jan Engelhardt jengelh at inai.de
Tue Jan 15 15:17:32 PST 2013


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))


More information about the systemd-devel mailing list