flan/test/programs/res-leaks.flan

24 lines
892 B
Plaintext

;;;; A dev build counts what a library's Load calls hand out against its Unload
;;;; calls, and says at exit what was never released and where it was loaded.
;;;;
;;;; Three Things and two byte buffers are loaded. b is changed in place by
;;;; thing-grow before it is unloaded, so its key has to follow it. c and q are
;;;; never unloaded, and the report names their lines. The last unload is of
;;;; the library's own Thing, which nothing loaded, and is reported apart.
;;;; A release build prints "done" and nothing else.
(import res "pkgs/res")
(defn main [] i32
(let [a (res/load-thing 1)
b (res/load-thing 2)
c (res/load-thing 3)
p (res/load-bytes 8)
q (res/load-bytes 8)]
(res/thing-grow (addr b))
(res/unload-thing a)
(res/unload-thing b)
(res/unload-bytes p)
(res/unload-thing (res/get-default-thing))
(println "done"))
0)