@@ -415,12 +415,11 @@ struct media_device *media_open(const char *name, int verbose)
struct media_private *priv;
int ret;
- media = malloc(sizeof(*media));
+ media = calloc(1, sizeof(*media));
if (media == NULL) {
printf("%s: unable to allocate memory\n", __func__);
return NULL;
}
- memset(media, 0, sizeof(*media));
if (verbose)
printf("Opening media device %s\n", name);
@@ -431,13 +430,12 @@ struct media_device *media_open(const char *name, int verbose)
return NULL;
}
- priv = malloc(sizeof(*priv));
+ priv = calloc(1, sizeof(*priv));
if (priv == NULL) {
printf("%s: unable to allocate memory\n", __func__);
media_close(media);
return NULL;
}
- memset(priv, 0, sizeof(*priv));
/* Fill the private structure */
priv->media = media;
The code snippet x = malloc(sizeof(*x)); memset(x, 0, sizeof(*x)); could be easily changed to x = calloc(1, sizeof(*x)); Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> --- src/media.c | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-)