]> git.sesse.net Git - vlc/blobdiff - modules/video_filter/dynamicoverlay/dynamicoverlay_buffer.c
Fix encoding (and writing).
[vlc] / modules / video_filter / dynamicoverlay / dynamicoverlay_buffer.c
index e24518ad4a1fa349b8c256d2c2d9aad6c0b99fc8..b454ebf5b8db04c9279b534fd61f04616c882f9a 100644 (file)
@@ -1,10 +1,10 @@
 /*****************************************************************************
  * 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
@@ -121,24 +121,14 @@ int BufferPrintf( buffer_t *p_buffer, const char *p_fmt, ... )
     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;