[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Avoid a warning from the use of floating-point in zstd



commit 4038202f89d97caf4d0a0b2d44d4111c4c4b2422
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Wed Apr 26 14:21:45 2017 -0400

    Avoid a warning from the use of floating-point in zstd
    
    Replace "(preset - 0.5) * 1mb" with "preset * 1mb - 0.5 mb", to
    avoid warning about converting double to size_t.
---
 src/common/compress_zstd.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/common/compress_zstd.c b/src/common/compress_zstd.c
index 4a8f03e..40b5412 100644
--- a/src/common/compress_zstd.c
+++ b/src/common/compress_zstd.c
@@ -145,7 +145,8 @@ tor_zstd_state_size_precalc(int compress, int preset)
     // variables that are not exposed via the public API. We use a _very_
     // simplified function to calculate the estimated amount of bytes used in
     // this struct.
-    memory_usage += (preset - 0.5) * 1024 * 1024;
+    // memory_usage += (preset - 0.5) * 1024 * 1024;
+    memory_usage += (preset * 1024 * 1024) - (512 * 1024);
     // - ZSTD_sizeof_CDict(stream->cdictLocal): Unused in Tor: 0 bytes.
     // - stream->outBuffSize: 128 KB:
     memory_usage += 128 * 1024;

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits