-}
-#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;
- }
- }
-}