14 const size_t base_len = base ? strlen(base) : 0;
15 const int size = fmtlen(
fmt, args);
16 if (size < 0)
return -1;
17 char *ret =
mp_malloc2(mp, base_len + size + 1);
18 if (base) strcpy(ret, base);
19 const int final_len = vsprintf(ret + base_len,
fmt, args);
21 mp_free2(mp, base_len + size + 1, ret);
24 if (base)
mp_free2(mp, strlen(base), base);