diff mbox

[media-ctl,PATCHv5,5/5] libmediactl: get rid of memset via using calloc

Message ID c6fb27f616b6e6b0b99e690109ba6a2466ba980d.1315236211.git.andriy.shevchenko@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Andy Shevchenko Sept. 5, 2011, 3:24 p.m. UTC
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(-)
diff mbox

Patch

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;