hello,
I have found two methods to get an initilized array:
implement main(argc, argv) = let
fun{a:t@ype} data{n: nat} (arr: &(@[a][n])): void = ()
var !p_arr1 = @[float](0.9f, ~1.8f, 2.7f, 3.6f, 4.5f, 5.4f, 6.3f, 7.2f,
8.1f, 9.0f)
val () = data(!p_arr1)
val (pf_gc, pf_arr2|p_arr2, sz) = $arrsz {float}(0.9f, 1.8f, 2.7f, 3.6f,
4.5f, 5.4f, 6.3f, 7.2f, 8.1f, 9.0f)
val () = data(!p_arr2)
in
array_ptr_free(pf_gc, pf_arr2|p_arr2)
end
memory of p_arr2 can be released with array_ptr_free
Is the memory allocated by p_arr1 is on the heap same as C and is released
when the scope of the function is destroyed or is it garbage collected ?
thanks