libcsdbg  1.28
C++ exception (and generic) stack trace debug library
i8 * csdbg::util::va_format ( i8 dst,
const i8 fmt,
va_list  args 
)
static

Format a buffer with a printf-style string expanded with the values of a variable argument list.

Parameters
[out]dstthe buffer to be formatted. Use util::va_size to compute the suitable buffer size to avoid memory overflows. If NULL a proper buffer is allocated
[in]fmta printf-style format string
[in]argsa variable argument list (as a va_list variable)
Returns
the formatted string
Exceptions
std::bad_alloc
csdbg::exception

Definition at line 568 of file util.cpp.

References unlikely, and va_format().

569 {
570  if ( unlikely(fmt == NULL) ) {
571  va_end(args);
572  throw exception("invalid argument: fmt (=%p)", fmt);
573  }
574 
575  if ( unlikely(dst == NULL) )
576  return va_format(fmt, args);
577 
578  i32 sz = vsprintf(dst, fmt, args);
579  va_end(args);
580  if ( unlikely(sz < 0) )
581  throw exception("vsprintf failed with retval %d", sz);
582 
583  return dst;
584 }
static i8 * va_format(const i8 *, va_list)
Format a buffer with a printf-style string expanded with the values of a variable argument list...
Definition: util.cpp:519
int i32
32-bit signed integer
Definition: config.hpp:82
#define unlikely(expr)
Offer a hint (negative) to the pipeline branch predictor.
Definition: config.hpp:349

+ Here is the call graph for this function: