Skip to content

Commit

Permalink
Protect my leaks
Browse files Browse the repository at this point in the history
  • Loading branch information
filipeom committed Jun 25, 2024
1 parent d6d1ca5 commit 7ddbab5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions lib/bitwuzla_mappings.default.ml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ include Mappings_intf

let _debug = false

let leaky_list = ref []
let leak =
let leaky_list = ref [] in
let mutex = Mutex.create () in
fun module_ ->
Mutex.lock mutex;
leaky_list := module_ :: !leaky_list;
Mutex.unlock mutex

module Fresh_bitwuzla (B : Bitwuzla_cxx.S) : M = struct
open B
Expand Down Expand Up @@ -416,7 +422,7 @@ include (
module Make () = struct
let bitwuzla = (module Bitwuzla_cxx.Make () : Bitwuzla_cxx.S)

let () = leaky_list := bitwuzla :: !leaky_list
let () = leak bitwuzla

include Fresh_bitwuzla ((val bitwuzla))
end
Expand Down
2 changes: 1 addition & 1 deletion lib/dune
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
(select
bitwuzla_mappings.ml
from
(bitwuzla-cxx -> bitwuzla_mappings.default.ml)
(threads bitwuzla-cxx -> bitwuzla_mappings.default.ml)
(-> bitwuzla_mappings.nop.ml))
(select
z3_mappings.ml
Expand Down

0 comments on commit 7ddbab5

Please sign in to comment.