* interface, such as message output. See config.h for output configuration.
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
- * $Id: intf_msg.c,v 1.29 2001/04/25 06:56:47 benny Exp $
+ * $Id: intf_msg.c,v 1.30 2001/04/25 09:31:14 sam Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
*
{
char psz_date[MSTRTIME_MAX_SIZE]; /* formatted time buffer */
int i_msg_len = MSTRTIME_MAX_SIZE + strlen(p_msg->psz_msg) + 200;
- char psz_msg[i_msg_len]; /* message buffer */
+ char *psz_msg; /* message buffer */
+
+ psz_msg = malloc( sizeof( char ) * i_msg_len );
+
+ /* Check if allocation succeeded */
+ if( psz_msg == NULL )
+ {
+ fprintf( stderr, "error: not enough memory for message %s\n",
+ p_msg->psz_msg );
+ return;
+ }
/* Format message - the message is formatted here because in case the log
* file is used, it avoids another format string parsing */
break;
}
- /* Check if formatting function succeeded */
- if( psz_msg == NULL )
- {
- fprintf( stderr, "error: can not format message (%s): %s\n",
- strerror( errno ), p_msg->psz_msg );
- return;
- }
-
/*
* Print messages
*/
fwrite( "\n", 1, 1, p_main->p_msg->p_log_file );
}
#endif
+
+ /* Free the message */
+ free( psz_msg );
}
#else