Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- char *curl_mvaprintf(const char *format, va_list ap_save)
- {
- int retcode;
- struct asprintf info;
- info.buffer = NULL;
- info.len = 0;
- info.alloc = 0;
- info.fail = 0;
- retcode = dprintf_formatf(&info, alloc_addbyter, format, ap_save);
- if((-1 == retcode) || info.fail) {
- if(info.alloc)
- free(info.buffer);
- return NULL;
- }
- if(info.alloc) {
- info.buffer[info.len] = 0; /* we terminate this with a zero byte */
- return info.buffer;
- }
- return strdup("");
- }
- CURLcode Curl_add_bufferf(Curl_send_buffer *in, const char *fmt, ...)
- {
- char *s;
- va_list ap;
- va_start(ap, fmt);
- s = vaprintf(fmt, ap); /* this allocs a new string to append */
- va_end(ap);
- if(s) {
- CURLcode result = Curl_add_buffer(in, s, strlen(s));
- free(s);
- return result;
- }
- /* If we failed, we cleanup the whole buffer and return error */
- free(in->buffer);
- free(in);
- return CURLE_OUT_OF_MEMORY;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement