Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int alloc_snprintf(char** out, const char* template, ...)
- {
- va_list list;
- va_start(list, template);
- int len = vsnprintf(NULL, 0, template, list);
- va_end(list);
- char* new_string = malloc((size_t)len + 1);
- assert(new_string != NULL);
- *out = new_string;
- va_start(list, template);
- len = vsnprintf(new_string, (size_t)len+1, template, list);
- va_end(list);
- return len;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement