/*****************************************************************************
* dynamicoverlay_buffer.h : dynamic overlay buffer
*****************************************************************************
- * Copyright (C) 2008 the VideoLAN team
+ * Copyright (C) 2008-2009 the VideoLAN team
* $Id$
*
- * Author: SÃ\83¸ren BÃ\83¸g <avacore@videolan.org>
+ * Author: Søren Bøg <avacore@videolan.org>
* Jean-Paul Saman <jpsaman@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
# include "config.h"
#endif
-#include <vlc/vlc.h>
+#include <vlc_common.h>
#include <vlc_osd.h>
#include <vlc_filter.h>
int status;
char *psz_data;
- va_list va_list1, va_list2;
- va_start( va_list1, p_fmt );
- va_copy( va_list2, va_list1 );
+ va_list va;
+ va_start( va, p_fmt );
- i_len = vsnprintf( NULL, 0, p_fmt, va_list1 );
- if( i_len < 0 )
- return VLC_EGENERIC;
- va_end( va_list1 );
-
- psz_data = malloc( i_len + 1 );
- if( psz_data == NULL ) {
+ i_len = vasprintf( &psz_data, p_fmt, va );
+ va_end( va );
+ if( i_len == -1 )
return VLC_ENOMEM;
- }
- if( vsnprintf( psz_data, i_len + 1, p_fmt, va_list2 ) != i_len )
- {
- return VLC_EGENERIC;
- }
- va_end( va_list2 );
+
status = BufferAdd( p_buffer, psz_data, i_len );
free( psz_data );
return status;