flan/test/programs/temp-grow.flan

21 lines
811 B
Plaintext

;;;; The temp allocator grows instead of failing. A Vec in it that is the
;;;; newest block and outgrows the current chunk is moved to a bigger one rather
;;;; than refused, whether it was made under with-allocator or named directly.
;;;;
;;;; Then text kept past a (free-temp) without a clone: a dev build has filled
;;;; the wiped bytes with 0xDEADBEEF, so its first byte reads 239 (0xEF); a
;;;; release build leaves the old text, whose first byte is the digit 4 (52).
(defn main [] i32
(with-allocator context/temp
(let [v (vec-new u8)]
(dotimes [i 3000000] (push v (u8 1)))
(println (length v))))
(let [w (vec-new u8 context/temp)]
(dotimes [i 3000000] (push w (u8 1)))
(println (length w)))
(free-temp)
(let [s (i64->bytes 42)]
(free-temp)
(println (at s 0)))
0)