]> git.sesse.net Git - vlc/commitdiff
Fix some brain-damaged calloc use
authorRémi Denis-Courmont <rem@videolan.org>
Sat, 1 Mar 2008 17:42:57 +0000 (17:42 +0000)
committerRémi Denis-Courmont <rem@videolan.org>
Sat, 1 Mar 2008 17:42:57 +0000 (17:42 +0000)
(Hint: sizeof(char) is ONE per the definition of sizeof)
(Hint: size is the SECOND parameter of calloc, not the FIRST one)
(Hint: calloc() calls bzero(), waste of time if memory is set anyway)

modules/demux/mp4/libmp4.c

index 426890ff026a00375be07330daf29f9760f275dc..6fe3657d823bdb4df37bce0b0d62329010b08c26 100644 (file)
@@ -67,7 +67,7 @@
     if( (i_read > 0) && (p_peek[0]) )   \
     {       \
         const int __i_copy__ = strnlen( (char*)p_peek, i_read-1 );  \
-        p_str = calloc( sizeof(char), __i_copy__+1 );               \
+        p_str = malloc( __i_copy__+1 );               \
         if( __i_copy__ > 0 ) memcpy( p_str, p_peek, __i_copy__ );   \
         p_str[__i_copy__] = 0;      \
         p_peek += __i_copy__ + 1;   \
@@ -603,7 +603,7 @@ static int MP4_ReadBox_hdlr( stream_t *p_stream, MP4_Box_t *p_box )
 
     if( i_read > 0 )
     {
-        p_box->data.p_hdlr->psz_name = calloc( sizeof( char ), i_read + 1 );
+        p_box->data.p_hdlr->psz_name = malloc( i_read + 1 );
 
         /* Yes, I love .mp4 :( */
         if( p_box->data.p_hdlr->i_predefined == VLC_FOURCC( 'm', 'h', 'l', 'r' ) )
@@ -890,7 +890,7 @@ static int MP4_ReadBox_esds( stream_t *p_stream, MP4_Box_t *p_box )
             unsigned int i_len;
 
             MP4_GET1BYTE( i_len );
-            es_descriptor.psz_URL = calloc( sizeof(char), i_len + 1 );
+            es_descriptor.psz_URL = malloc( i_len + 1 );
             memcpy( es_descriptor.psz_URL, p_peek, i_len );
             es_descriptor.psz_URL[i_len] = 0;
             p_peek += i_len;