[systemd-devel] [PATCH 3/3] bootchart: Convert malloc/memset to calloc.
Lennart Poettering
lennart at poettering.net
Tue Jan 15 11:47:54 PST 2013
On Thu, 10.01.13 11:35, Auke Kok (auke-jan.h.kok at intel.com) wrote:
Heya, just a few notes.
> ---
> src/bootchart/bootchart.c | 5 ++---
> src/bootchart/log.c | 10 ++++------
> 2 files changed, 6 insertions(+), 9 deletions(-)
>
> diff --git a/src/bootchart/bootchart.c b/src/bootchart/bootchart.c
> index 7bcfd98..37d8fbe 100644
> --- 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 (!ps_first) {
> - perror("malloc(ps_struct)");
> + perror("calloc(ps_struct)");
And we have log_oom() for this specific message.
Lennart
--
Lennart Poettering - Red Hat, Inc.
More information about the systemd-devel
mailing list