Make some utility functions return std::string to simplify code (#2368)

* tr_formatter_speed_KBps returns std::string

* tr_formatter_mem_B returns std::string

* tr_formatter_size_B returns std::string

* tr_strpercent/tr_strratio returns std::string
This commit is contained in:
Mike Gelfand
2021-12-31 00:30:21 +00:00
committed by GitHub
parent 26110d5c8e
commit d8d361e491
15 changed files with 146 additions and 252 deletions

View File

@@ -248,13 +248,14 @@ static int getMaxBlocks(int64_t max_bytes)
int tr_cacheSetLimit(tr_cache* cache, int64_t max_bytes)
{
char buf[128];
cache->max_bytes = max_bytes;
cache->max_blocks = getMaxBlocks(max_bytes);
tr_formatter_mem_B(buf, cache->max_bytes, sizeof(buf));
tr_logAddNamedDbg(MY_NAME, "Maximum cache size set to %s (%d blocks)", buf, cache->max_blocks);
tr_logAddNamedDbg(
MY_NAME,
"Maximum cache size set to %s (%d blocks)",
tr_formatter_mem_B(cache->max_bytes).c_str(),
cache->max_blocks);
return cacheTrim(cache);
}