]> git.sesse.net Git - vlc/blobdiff - src/extras/libc.c
* modules/packetizer/mpeg4audio.c, modules/packetizer/mpegvideo.c: compilation fix.
[vlc] / src / extras / libc.c
index 6b44f44d4581ea5404eee1afc0ffd2419a6859f2..cad26a92a567849a464f6507ab6bbd65e6dbedb9 100644 (file)
@@ -2,7 +2,7 @@
  * libc.c: Extra libc function for some systems.
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: libc.c,v 1.11 2004/01/07 23:39:41 fenrir Exp $
+ * $Id: libc.c,v 1.16 2004/02/09 16:12:25 sigmunau Exp $
  *
  * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
  *          Samuel Hocevar <sam@zoy.org>
@@ -130,7 +130,7 @@ int vlc_strncasecmp( const char *s1, const char *s2, size_t n )
 /*****************************************************************************
  * vasprintf:
  *****************************************************************************/
-#if !defined( HAVE_VASPRINTF )
+#if !defined(HAVE_VASPRINTF) || defined(SYS_DARWIN) || defined(SYS_BEOS)
 int vlc_vasprintf(char **strp, const char *fmt, va_list ap)
 {
     /* Guess we need no more than 100 bytes. */
@@ -147,7 +147,7 @@ int vlc_vasprintf(char **strp, const char *fmt, va_list ap)
     for( ;; )
     {
         /* Try to print in the allocated space. */
-        n = vsnprintf( p, i_size, fmt, args );
+        n = vsnprintf( p, i_size, fmt, ap );
 
         /* If that worked, return the string. */
         if (n > -1 && n < i_size)
@@ -173,6 +173,23 @@ int vlc_vasprintf(char **strp, const char *fmt, va_list ap)
 }
 #endif
 
+/*****************************************************************************
+ * asprintf:
+ *****************************************************************************/
+#if !defined(HAVE_ASPRINTF) || defined(SYS_DARWIN) || defined(SYS_BEOS)
+int vlc_asprintf( char **strp, const char *fmt, ... )
+{
+    va_list args;
+    int i_ret;
+
+    va_start( args, fmt );
+    i_ret = vasprintf( strp, fmt, args );
+    va_end( args );
+
+    return i_ret;
+}
+#endif
+
 /*****************************************************************************
  * atof: convert a string to a double.
  *****************************************************************************/
@@ -208,7 +225,7 @@ int64_t vlc_atoll( const char *str )
 
     while( *str >= '0' && *str <= '9' )
     {
-        i_value = i_value * 10 + ( *str - '0' );
+        i_value = i_value * 10 + ( *str++ - '0' );
     }
 
     return i_value * sign;