/** * Formats the given format string and arguments and allocates a new string (ret) * * NOTE: Included because asprintf is not included on Windows */ int xp_asprintf(char** ret, const char* format, ...) { int retval; va_list arglist; va_start(arglist, format); retval = xp_vasprintf(ret, format, arglist); va_end(arglist); return retval; }
/** * Appends the formatted string to the given string builder */ void sb_append_strf(stringbuilder* sb, const char* fmt, ...) { char *str; va_list arglist; va_start(arglist, fmt); xp_vasprintf(&str, fmt, arglist); va_end(arglist); if (!str) { return; } sb_append_str(sb, str); free(str); }