package albatross

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

Install

Dune Dependency

Authors

Maintainers

Sources

albatross-2.4.1.tbz
sha256=fca03a99220d743386ed97900271e2fb1e38c48c56f10faa2a47757fc931db8e
sha512=ee608bcd42047f702bfe6007f664dc10d71faa4f2aeaedf278802c58f6b3bcfe35d53ebcb73f5e3ce59bbc9e6bfa8f27e81051d10a690876fa035b0279e950da

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
35
36
37
38
39
let compress ?level input =
  let level =
    match level with
    | Some x when x >= 0 && x <= 9 -> x
    | _ -> 4
  in
  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.