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@xxxxxxxxxxxxxxx> --- src/media.c | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/media.c b/src/media.c index 6c03369..38ebaac 100644 --- a/src/media.c +++ b/src/media.c @@ -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; -- 1.7.5.4 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html