Skip to content

Commit

Permalink
Add optional arg and remove cflag warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Kruhlmann committed Apr 9, 2024
1 parent 4fbfc6b commit 73b6f44
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions lib/compression/domain.ml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/dune
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down

0 comments on commit 73b6f44

Please sign in to comment.