aboutsummaryrefslogtreecommitdiff
path: root/src/common/compress.c
diff options
context:
space:
mode:
authorAlexander Færøy <ahf@torproject.org>2017-04-20 15:33:13 +0200
committerNick Mathewson <nickm@torproject.org>2017-04-25 08:10:09 -0400
commit04682d302aeeb0c2a0d9859bc0c1feee38daf16a (patch)
tree1c47cbb8c7d1bd711951e73ec9ddc61d914db975 /src/common/compress.c
parentbe4dc546345831773c2e16fa3dc12749d925aa25 (diff)
downloadtor-04682d302aeeb0c2a0d9859bc0c1feee38daf16a.tar.gz
tor-04682d302aeeb0c2a0d9859bc0c1feee38daf16a.zip
Add `tor_compress_get_total_allocation()` function.
This patch adds the `tor_compress_get_total_allocation()` which returns an approximate number of bytes currently in use by all the different compression backends. See: https://bugs.torproject.org/21662
Diffstat (limited to 'src/common/compress.c')
-rw-r--r--src/common/compress.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/common/compress.c b/src/common/compress.c
index dc86be7750..52ff13258a 100644
--- a/src/common/compress.c
+++ b/src/common/compress.c
@@ -154,6 +154,16 @@ detect_compression_method(const char *in, size_t in_len)
}
}
+/** Return the approximate number of bytes allocated for all
+ * supported compression schemas. */
+size_t
+tor_compress_get_total_allocation(void)
+{
+ return tor_zlib_get_total_allocation() +
+ tor_lzma_get_total_allocation() +
+ tor_zstd_get_total_allocation();
+}
+
/** Internal state for an incremental compression/decompression. The body of
* this struct is not exposed. */
struct tor_compress_state_t {