[libdvdnav-devel] Use calloc instead of malloc+memset

Jean-Baptiste Kempf git at videolan.org
Thu Jul 31 01:43:16 CEST 2014


libdvdnav | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Thu Jul 31 01:42:42 2014 +0200| [e46237a7b37bb53e9819ec821405f22e6b51c354] | committer: Jean-Baptiste Kempf

Use calloc instead of malloc+memset

> http://git.videolan.org/gitweb.cgi/libdvdnav.git/?a=commit;h=e46237a7b37bb53e9819ec821405f22e6b51c354
---

 src/dvdnav.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/dvdnav.c b/src/dvdnav.c
index 8369f97..d8da517 100644
--- a/src/dvdnav.c
+++ b/src/dvdnav.c
@@ -138,10 +138,9 @@ dvdnav_status_t dvdnav_open(dvdnav_t** dest, const char *path) {
   fprintf(MSG_OUT, "libdvdnav: Using dvdnav version %s\n", VERSION);
 
   (*dest) = NULL;
-  this = (dvdnav_t*)malloc(sizeof(dvdnav_t));
+  this = (dvdnav_t*)calloc(1, sizeof(dvdnav_t));
   if(!this)
     return DVDNAV_STATUS_ERR;
-  memset(this, 0, (sizeof(dvdnav_t) ) ); /* Make sure this structure is clean */
 
   pthread_mutex_init(&this->vm_lock, NULL);
   /* Initialise the error string */



More information about the libdvdnav-devel mailing list