Skip to content

Commit

Permalink
report.c: mock vasprintf for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
yamt committed Aug 12, 2024
1 parent b253b8a commit 73ce93e
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions lib/report.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,30 @@
#include "report.h"
#include "xlog.h"

#if defined(_MSC_VER)
int
vasprintf(char **resultp, const char *fmt, va_list ap)
{
int ret = vsnprintf(NULL, 0, fmt, ap);
if (ret < 0) {
return ret;
}
size_t bufsz = ret + 1; /* +1 for the terminating NUL */
char *p = malloc(bufsz);
if (p == NULL) {
return -1;
}
int ret = vsnprintf(p, bufsz, fmt, ap);
if (ret < 0) {
free(p);
return ret;
}
assert(ret + 1 == bufsz);
*resultp = p;
return ret;
}
#endif

void
vreport(struct report *r, const char *fmt, va_list ap)
{
Expand Down

0 comments on commit 73ce93e

Please sign in to comment.