]> git.sesse.net Git - vlc/commitdiff
* revert the rewrite of MP4_GETSTRINGZ in the previous commit, as strnlen is a GNU...
authorFelix Paul Kühne <fkuehne@videolan.org>
Mon, 28 May 2007 11:13:48 +0000 (11:13 +0000)
committerFelix Paul Kühne <fkuehne@videolan.org>
Mon, 28 May 2007 11:13:48 +0000 (11:13 +0000)
modules/demux/mp4/libmp4.c

index 60ce1273f9b4cc978edf5e7b88edd01cb2b6b913..b35eb71dec6595d765cf5a07269237606d01f2c6 100644 (file)
     MP4_GET1BYTE( p_void->i_version ); \
     MP4_GET3BYTES( p_void->i_flags )
 
-#define MP4_GETSTRINGZ( p_str )         \
-    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 );               \
-        if( __i_copy__ > 0 ) memcpy( p_str, p_peek, __i_copy__ );   \
-        p_str[__i_copy__] = 0;      \
-        p_peek += __i_copy__ + 1;   \
-        i_read -= __i_copy__ + 1;   \
-    }       \
-    else    \
-    {       \
+#define MP4_GETSTRINGZ( p_str ) \
+    if( ( i_read > 0 )&&(p_peek[0] ) ) \
+    { \
+        p_str = calloc( sizeof( char ), __MIN( strlen( (char*)p_peek ), i_read )+1);\
+        memcpy( p_str, p_peek, __MIN( strlen( (char*)p_peek ), i_read ) ); \
+        p_str[__MIN( strlen( (char*)p_peek ), i_read )] = 0; \
+        p_peek += strlen( (char *)p_str ) + 1; \
+        i_read -= strlen( (char *)p_str ) + 1; \
+    } \
+    else \
+    { \
         p_str = NULL; \
     }
 
-
 #define MP4_READBOX_ENTER( MP4_Box_data_TYPE_t ) \
     int64_t  i_read = p_box->i_size; \
     uint8_t *p_peek, *p_buff; \