]> git.sesse.net Git - vlc/commitdiff
Inline and fix some linking errors
authorRémi Denis-Courmont <rem@videolan.org>
Sat, 24 May 2008 16:57:58 +0000 (19:57 +0300)
committerRémi Denis-Courmont <rem@videolan.org>
Sat, 24 May 2008 16:57:58 +0000 (19:57 +0300)
Should fix strlcpy() issues on Linux, but Win32 is surely still totally
broken by d754b40584b5fd5ffd5f39a2288a14f9f4662f78

include/vlc_common.h
include/vlc_fixups.h
src/extras/libc.c
src/libvlccore.sym

index 169a1a216fcf0885d00e600604880b859cfef6ce..33c9e63bbb2afab5ccd9abaafa5a7e52e5822897 100644 (file)
@@ -719,8 +719,6 @@ static inline void _SetQWBE( uint8_t *p, uint64_t i_qw )
 #define VLC_UNUSED(x) (void)(x)
 
 /* Stuff defined in src/extras/libc.c */
-VLC_EXPORT( int, vlc_vasprintf, (char **, const char *, va_list ) );
-VLC_EXPORT( int, vlc_asprintf, (char **, const char *, ... ) ATTRIBUTE_FORMAT( 2, 3 ) );
 VLC_EXPORT( size_t, vlc_strlcpy, ( char *, const char *, size_t ) );
 VLC_EXPORT( long long, vlc_strtoll, ( const char *nptr, char **endptr, int base ) );
 
index 55505992ce4a3d6f6ba455c5c1e96764607b7d17..42dbfbf51e6949050176c00a3865feed61238ccc 100644 (file)
@@ -40,11 +40,29 @@ static inline char *strdup (const char *str)
 #endif
 
 #ifndef HAVE_VASPRINTF
-# define vasprintf vlc_vasprintf
+# include <stdarg.h>
+static inline int vasprintf (char **strp, const char *fmt, va_list ap)
+{
+    int len = vsnprintf (NULL, 0, fmt, ap) + 1;
+    char *res = malloc (len);
+    if (res == NULL)
+        return -1;
+    *strp = res;
+    return vsprintf (res, fmt, ap);
+}
 #endif
 
 #ifndef HAVE_ASPRINTF
-# define asprintf vlc_asprintf
+# include <stdarg.h>
+static inline int asprintf (char **strp, const char *fmt, ...)
+{
+    va_list ap;
+    int ret;
+    va_start (fmt, ap);
+    ret = vasprintf (strp, fmt, ap);
+    va_end (ap);
+    return ret;
+}
 #endif
 
 #ifndef HAVE_STRNLEN
index f2b9019917ea4880f959b9dbacdc805d02ef0cb0..a887c2d2cca85d8050ee4f359ce28757711d694b 100644 (file)
  * strcasestr: find a substring (little) in another substring (big)
  * Case sensitive. Return NULL if not found, return big if little == null
  *****************************************************************************/
-#if !defined( HAVE_STRCASESTR ) && !defined( HAVE_STRISTR )
 char * vlc_strcasestr( const char *psz_big, const char *psz_little )
 {
+#if defined (HAVE_STRCASESTR) || defined (HAVE_STRISTR)
+    return strcasestr (psz_big, psz_little);
+#else
     char *p_pos = (char *)psz_big;
 
     if( !psz_big || !psz_little || !*psz_little ) return p_pos;
@@ -98,71 +100,8 @@ char * vlc_strcasestr( const char *psz_big, const char *psz_little )
         p_pos++;
     }
     return NULL;
-}
-#endif
-
-/*****************************************************************************
- * vasprintf:
- *****************************************************************************/
-#if !defined(HAVE_VASPRINTF) || defined(__APPLE__) || defined(SYS_BEOS)
-int vlc_vasprintf(char **strp, const char *fmt, va_list ap)
-{
-    /* Guess we need no more than 100 bytes. */
-    int     i_size = 100;
-    char    *p = malloc( i_size );
-    int     n;
-
-    if( p == NULL )
-    {
-        *strp = NULL;
-        return -1;
-    }
-
-    for( ;; )
-    {
-        /* Try to print in the allocated space. */
-        n = vsnprintf( p, i_size, fmt, ap );
-
-        /* If that worked, return the string. */
-        if (n > -1 && n < i_size)
-        {
-            *strp = p;
-            return strlen( p );
-        }
-        /* Else try again with more space. */
-        if (n > -1)    /* glibc 2.1 */
-        {
-           i_size = n+1; /* precisely what is needed */
-        }
-        else           /* glibc 2.0 */
-        {
-           i_size *= 2;  /* twice the old size */
-        }
-        if( (p = realloc( p, i_size ) ) == NULL)
-        {
-            *strp = NULL;
-            return -1;
-        }
-    }
-}
 #endif
-
-/*****************************************************************************
- * asprintf:
- *****************************************************************************/
-#if !defined(HAVE_ASPRINTF) || defined(__APPLE__) || 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
 
 /*****************************************************************************
  * strtoll: convert a string to a 64 bits int.
@@ -249,9 +188,11 @@ long long vlc_strtoll( const char *nptr, char **endptr, int base )
  *
  * @return strlen(src)
  */
-#ifndef HAVE_STRLCPY
 extern size_t vlc_strlcpy (char *tgt, const char *src, size_t bufsize)
 {
+#ifdef HAVE_STRLCPY
+    return strlcpy (tgt, src, bufsize);
+#else
     size_t length;
 
     for (length = 1; (length < bufsize) && *src; length++)
@@ -264,8 +205,8 @@ extern size_t vlc_strlcpy (char *tgt, const char *src, size_t bufsize)
         length++;
 
     return length - 1;
-}
 #endif
+}
 
 /*****************************************************************************
  * vlc_*dir_wrapper: wrapper under Windows to return the list of drive letters
index c9d01abd7cdc107533b4ce335697a47ecd3ba1fd..430adc72a8d0ab97b4ab3bf627c86878d0f87a81 100644 (file)
@@ -367,7 +367,6 @@ __var_Get
 __var_Set
 __var_TriggerCallback
 __var_Type
-vlc_asprintf
 vlc_b64_decode
 vlc_b64_decode_binary
 vlc_b64_decode_binary_to_buffer
@@ -431,6 +430,7 @@ __vlc_object_yield
 vlc_pthread_fatal
 vlc_rand_bytes
 vlc_sdp_Start
+vlc_strlcpy
 vlc_strtoll
 vlc_submodule_create
 __vlc_thread_create
@@ -440,7 +440,6 @@ __vlc_thread_set_priority
 vlc_threadvar_create
 vlc_threadvar_delete
 vlc_ureduce
-vlc_vasprintf
 VLC_Version
 vlc_wraptext
 vlm_Control