Commit 5d3ffa0e authored by Pierre Ynard's avatar Pierre Ynard

Add us_vasprintf() function

For use within already variadic functions
parent 888f4987
......@@ -114,6 +114,7 @@ VLC_EXPORT( void *, ToCharset, ( const char *charset, const char *in, size_t *ou
VLC_EXPORT( double, us_strtod, ( const char *, char ** ) LIBVLC_USED );
VLC_EXPORT( float, us_strtof, ( const char *, char ** ) LIBVLC_USED );
VLC_EXPORT( double, us_atof, ( const char * ) LIBVLC_USED );
VLC_EXPORT( int, us_vasprintf, ( char **, const char *, va_list ) );
VLC_EXPORT( int, us_asprintf, ( char **, const char *, ... ) LIBVLC_USED );
#endif
......@@ -453,6 +453,7 @@ us_asprintf
us_atof
us_strtod
us_strtof
us_vasprintf
vlc_fopen
utf8_fprintf
vlc_loaddir
......
......@@ -92,19 +92,15 @@ double us_atof( const char *str )
/**
* us_asprintf() has the same prototype as asprintf(), but doesn't use
* us_vasprintf() has the same prototype as vasprintf(), but doesn't use
* the system locale.
*/
int us_asprintf( char **ret, const char *format, ... )
int us_vasprintf( char **ret, const char *format, va_list ap )
{
va_list ap;
locale_t loc = newlocale( LC_NUMERIC_MASK, "C", NULL );
locale_t oldloc = uselocale( loc );
int i_rc;
va_start( ap, format );
i_rc = vasprintf( ret, format, ap );
va_end( ap );
int i_rc = vasprintf( ret, format, ap );
if ( loc != (locale_t)0 )
{
......@@ -114,3 +110,20 @@ int us_asprintf( char **ret, const char *format, ... )
return i_rc;
}
/**
* us_asprintf() has the same prototype as asprintf(), but doesn't use
* the system locale.
*/
int us_asprintf( char **ret, const char *format, ... )
{
va_list ap;
int i_rc;
va_start( ap, format );
i_rc = us_vasprintf( ret, format, ap );
va_end( ap );
return i_rc;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment