- /* Convert message to string */
-#if defined(HAVE_VASPRINTF) && !defined(__APPLE__) && !defined( SYS_BEOS )
- vlc_va_copy( args, _args );
- if( vasprintf( &psz_str, psz_format, args ) == -1 )
- psz_str = NULL;
- va_end( args );
-#else
- psz_str = (char*) malloc( i_size );
-#endif
-
- if( psz_str == NULL )
- {
- int canc = vlc_savecancel (); /* Do not print half of a message... */
-#ifdef __GLIBC__
- fprintf( stderr, "main warning: can't store message (%m): " );
-#else
- char psz_err[1001];
-#ifndef WIN32
- /* we're not using GLIBC, so we are sure that the error description
- * will be stored in the buffer we provide to strerror_r() */
- strerror_r( errno, psz_err, 1001 );
-#else
- strncpy( psz_err, strerror( errno ), 1001 );
-#endif
- psz_err[1000] = '\0';
- fprintf( stderr, "main warning: can't store message (%s): ", psz_err );
-#endif
- vlc_va_copy( args, _args );
- /* We should use utf8_vfprintf - but it calls malloc()... */
- vfprintf( stderr, psz_format, args );
- va_end( args );
- fputs( "\n", stderr );
- vlc_restorecancel (canc);
- return;
- }
-
- i_header_size = 0;
- p_obj = p_this;
- while( p_obj != NULL )
- {
- char *psz_old = NULL;
- if( p_obj->psz_header )
- {
- i_header_size += strlen( p_obj->psz_header ) + 4;
- if( psz_header )
- {
- psz_old = strdup( psz_header );
- psz_header = (char*)realloc( psz_header, i_header_size );
- snprintf( psz_header, i_header_size , "[%s] %s",
- p_obj->psz_header, psz_old );
- }
- else
- {
- psz_header = (char *)malloc( i_header_size );
- snprintf( psz_header, i_header_size, "[%s]",
- p_obj->psz_header );
- }
- }
- free( psz_old );
- p_obj = p_obj->p_parent;
- }
-
-#if !defined(HAVE_VASPRINTF) || defined(__APPLE__) || defined(SYS_BEOS)
- vlc_va_copy( args, _args );
- vsnprintf( psz_str, i_size, psz_format, args );
- va_end( args );
- psz_str[ i_size - 1 ] = 0; /* Just in case */
-#endif
-
- LOCK_BANK;
- p_queue = &QUEUE;
- vlc_mutex_lock( &p_queue->lock );