/usr/share/doc/libres-ocaml-dev/examples/weak_ex.ml is in libres-ocaml-dev 4.0.3-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | (* Demonstrates the correct behaviour of resizable weak arrays. *)
module W = Res.Weak
module Array = W (* allows more convenient array access *)
class foo = object end
let ra = W.empty ()
let _ =
W.add_one ra (Some (new foo));
match ra.(0) with
| Some _ -> print_endline "Correctly allocated!"
| _ -> print_endline "Already deallocated??"
let _ =
Gc.full_major ();
match ra.(0) with
| Some _ -> print_endline "Still not deallocated?"
| _ -> print_endline "Correctly deallocated!"
|