From f3e48a4a0435ae17cff0b570d208a222fcd7fc58 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Thu, 15 Dec 2022 09:20:41 -0800 Subject: Replace malloc()+memset() with calloc() Signed-off-by: Alan Coopersmith --- src/smi_video.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/smi_video.c b/src/smi_video.c index 055f606..62de55d 100644 --- a/src/smi_video.c +++ b/src/smi_video.c @@ -552,25 +552,24 @@ SMI_BuildEncodings(SMI_PortPtr p) ENTER(); /* allocate memory for encoding array */ - p->enc = malloc(sizeof(XF86VideoEncodingRec) * N_ENCODINGS); + p->enc = calloc(N_ENCODINGS, sizeof(XF86VideoEncodingRec)); if (NULL == p->enc) goto fail; - memset(p->enc,0,sizeof(XF86VideoEncodingRec) * N_ENCODINGS); + /* allocate memory for video norm array */ - p->norm = malloc(sizeof(int) * N_ENCODINGS); + p->norm = calloc(N_ENCODINGS, sizeof(int)); if (NULL == p->norm) goto fail; - memset(p->norm,0,sizeof(int) * N_ENCODINGS); + /* allocate memory for video input format array */ - p->input = malloc(sizeof(int) * N_ENCODINGS); + p->input = calloc(N_ENCODINGS, sizeof(int)); if (NULL == p->input) goto fail; - memset(p->input,0,sizeof(int) * N_ENCODINGS); + /* allocate memory for video channel number array */ - p->channel = malloc(sizeof(int) * N_ENCODINGS); + p->channel = calloc(N_ENCODINGS, sizeof(int)); if (NULL == p->channel) goto fail; - memset(p->channel,0,sizeof(int) * N_ENCODINGS); /* fill arrays */ p->nenc = 0; -- cgit v1.2.3