tr_http_escape (buf, ipv6_readable, -1, true);
}
- return evbuffer_free_to_str (buf);
+ return evbuffer_free_to_str (buf, NULL);
}
static tr_pex*
delimiter = '&';
}
- return evbuffer_free_to_str (buf);
+ return evbuffer_free_to_str (buf, NULL);
}
void
evbuffer_add_printf (buf, "[%d:%s]", i, str);
}
- message = evbuffer_free_to_str (buf);
+ message = evbuffer_free_to_str (buf, NULL);
tr_logAddDeep (__FILE__, __LINE__, name, "announce queue is %s", message);
tr_free (message);
}
va_end (args);
evbuffer_add_printf (buf, " (%s:%d)", base, line);
/* FIXME (libevent2) ifdef this out for nonwindows platforms */
- message = evbuffer_free_to_str (buf);
+ message = evbuffer_free_to_str (buf, NULL);
OutputDebugStringA (message);
OutputDebugStringA (TR_NATIVE_EOL_STR);
if (fp != TR_BAD_SYS_FILE)
va_end (args);
evbuffer_add_printf (buf, " (%s:%d)", base, line);
- message = evbuffer_free_to_str (buf);
+ message = evbuffer_free_to_str (buf, NULL);
tr_sys_file_write_line (fp, message, NULL);
tr_free (base);
tr_http_escape (s, inf->webseeds[i], -1, true);
}
- return evbuffer_free_to_str (s);
+ return evbuffer_free_to_str (s, NULL);
}
****/
char*
-evbuffer_free_to_str (struct evbuffer * buf)
+evbuffer_free_to_str (struct evbuffer * buf,
+ size_t * result_len)
{
const size_t n = evbuffer_get_length (buf);
char * ret = tr_new (char, n + 1);
evbuffer_copyout (buf, ret, n);
evbuffer_free (buf);
ret[n] = '\0';
+ if (result_len != NULL)
+ *result_len = n;
return ret;
}
{
struct evbuffer * buf = evbuffer_new ();
evbuffer_add_vprintf (buf, fmt, args);
- return evbuffer_free_to_str (buf);
+ return evbuffer_free_to_str (buf, NULL);
}
const char*
strip_non_utf8 (const char * in, size_t inlen)
{
const char * end;
- const char zero = '\0';
struct evbuffer * buf = evbuffer_new ();
while (!tr_utf8_validate (in, inlen, &end))
}
evbuffer_add (buf, in, inlen);
- evbuffer_add (buf, &zero, 1);
- return evbuffer_free_to_str (buf);
+ return evbuffer_free_to_str (buf, NULL);
}
static char*
*/
int tr_strcmp0 (const char * str1, const char * str2);
-char* evbuffer_free_to_str (struct evbuffer * buf);
+char* evbuffer_free_to_str (struct evbuffer * buf,
+ size_t * result_len);
/** @brief similar to bsearch () but returns the index of the lower bound */
int tr_lowerBound (const void * key,
tr_variantToStr (const tr_variant * v, tr_variant_fmt fmt, int * len)
{
struct evbuffer * buf = tr_variantToBuf (v, fmt);
- const size_t n = evbuffer_get_length (buf);
- char * ret = evbuffer_free_to_str (buf);
+ size_t n;
+ char * ret = evbuffer_free_to_str (buf, &n);
if (len != NULL)
*len = (int) n;
return ret;
this_pass = MIN (remain, file->length - file_offset);
if (!urls[file_index])
- urls[file_index] = evbuffer_free_to_str (make_url (t->webseed, file));
+ urls[file_index] = evbuffer_free_to_str (make_url (t->webseed, file), NULL);
tr_snprintf (range, sizeof range, "%"PRIu64"-%"PRIu64,
file_offset, file_offset + this_pass - 1);
evbuffer_add (buf, str, strlen (str));
- return evbuffer_free_to_str (buf);
+ return evbuffer_free_to_str (buf, NULL);
}
static bool