package albatross

  1. Overview
  2. Docs
Albatross - orchestrate and manage MirageOS unikernels with Solo5

Install

dune-project
 Dependency

Authors

Maintainers

Sources

albatross-2.5.1.tbz
sha256=7bca10fb25e9effa8b06b8f4803c8f87514ca2f0c8115d98fd99cb2116e29cd9
sha512=b2d74503055e8583dcf6c1edfae9a054a56de0406de619a694d5ea9e8329b0e830f00ab032d3a2f575d6d161415436e3de184f2edaf860815e704c3364da8536

doc/src/albatross/vmm_compress.ml.html

Source file vmm_compress.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
let compress ~level input =
  let w = De.Lz77.make_window ~bits:15 in
  let q = De.Queue.create 0x1000 in
  let i = Bigstringaf.create De.io_buffer_size in
  let o = Bigstringaf.create De.io_buffer_size in
  let b = Buffer.create 0x1000 in
  let pos = ref 0 in
  let refill i =
    let len = min (Bigstringaf.length i) (String.length input - !pos) in
    Bigstringaf.blit_from_string input ~src_off:!pos i ~dst_off:0 ~len ;
    pos := !pos + len ; len in
  let flush o len =
    let str = Bigstringaf.substring o ~off:0 ~len in
    Buffer.add_string b str in
  Zl.Higher.compress ~level ~w ~q ~refill ~flush i o ;
  Buffer.contents b

let uncompress input =
  let w = De.make_window ~bits:15 in
  let allocate _ = w in
  let i = Bigstringaf.create De.io_buffer_size in
  let o = Bigstringaf.create De.io_buffer_size in
  let b = Buffer.create 0x1000 in
  let pos = ref 0 in
  let refill i =
    let len = min (Bigstringaf.length i) (String.length input - !pos) in
    Bigstringaf.blit_from_string input ~src_off:!pos i ~dst_off:0 ~len ;
    pos := !pos + len ; len in
  let flush o len =
    let str = Bigstringaf.substring o ~off:0 ~len in
    Buffer.add_string b str in
  match Zl.Higher.uncompress ~allocate ~refill ~flush i o with
  | Ok () -> Ok (Buffer.contents b)
  | Error _ as e -> e
OCaml

Innovation. Community. Security.