@ -115,25 +115,16 @@ static inline void strbuf_append(struct vrend_strbuf *sb, const char *addstr)
static inline void strbuf_vappendf ( struct vrend_strbuf * sb , const char * fmt , va_list ap )
static inline void strbuf_vappendf ( struct vrend_strbuf * sb , const char * fmt , va_list ap )
{
{
char buf [ 512 ] ;
va_list cp ;
va_list cp ;
va_copy ( cp , ap ) ;
va_copy ( cp , ap ) ;
int len = vsnprintf ( buf , sizeof ( buf ) , fmt , ap ) ;
int len = vsnprintf ( sb - > buf + sb - > size , sb - > alloc_size - sb - > size , fmt , ap ) ;
if ( len < ( int ) sizeof ( buf ) ) {
if ( len > = ( int ) ( sb - > alloc_size - sb - > size ) ) {
strbuf_append_buffer ( sb , buf , len ) ;
if ( ! strbuf_grow ( sb , len ) )
return ;
return ;
}
vsnprintf ( sb - > buf + sb - > size , sb - > alloc_size - sb - > size , fmt , cp ) ;
char * tmp = malloc ( len ) ;
if ( ! tmp ) {
strbuf_set_error ( sb ) ;
return ;
}
}
vsnprintf ( tmp , len , fmt , cp ) ;
sb - > size + = len ;
strbuf_append_buffer ( sb , tmp , len ) ;
free ( tmp ) ;
}
}
__attribute__ ( ( format ( printf , 2 , 3 ) ) )
__attribute__ ( ( format ( printf , 2 , 3 ) ) )