From 73b6f442e765c9ee3146014089dcef1ece3831ad Mon Sep 17 00:00:00 2001 From: Andreas Date: Tue, 9 Apr 2024 17:17:26 +0200 Subject: [PATCH] Add optional arg and remove cflag warnings --- lib/compression/domain.ml | 5 ++--- lib/dune | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/compression/domain.ml b/lib/compression/domain.ml index bd76535..64c1a07 100644 --- a/lib/compression/domain.ml +++ b/lib/compression/domain.ml @@ -1,4 +1,4 @@ -let decompress_base64 base64_str = +let decompress_base64 ?(buffer_size_factor = 12) base64_str = let compressed_data = Base64.decode_exn base64_str in let compressed_len = String.length compressed_data in let compressed_ba = Bigarray.Array1.create Bigarray.char Bigarray.c_layout compressed_len in @@ -8,14 +8,13 @@ let decompress_base64 base64_str = let inflate_state = Zlib.create_inflate () in inflate_state.Zlib.in_buf <- compressed_ba; inflate_state.Zlib.in_len <- compressed_len; - let output_len = compressed_len * 16 in + let output_len = compressed_len * buffer_size_factor in let output_ba = Bigarray.Array1.create Bigarray.char Bigarray.c_layout output_len in inflate_state.Zlib.out_buf <- output_ba; inflate_state.Zlib.out_len <- output_len; let status = Zlib.flate inflate_state Zlib.Finish in match status with | Zlib.Ok | Zlib.Stream_end -> - (* Successful decompression *) let result_len = output_len - inflate_state.Zlib.out_len in let result = String.init result_len (fun i -> Bigarray.Array1.get output_ba i) in Some result diff --git a/lib/dune b/lib/dune index 02cc43a..8dd29a2 100644 --- a/lib/dune +++ b/lib/dune @@ -8,7 +8,7 @@ (foreign_stubs (language c) (names zlib_stubs) - (flags -Wall -Wextra -Wno-unused-parameter -pedantic -std=c99 -fPIC)) + (flags -w -std=c99 -fPIC)) (c_library_flags -lz) (instrumentation (backend bisect_ppx)))