1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
use crate;
use cratec_arrayCArray;
/// Converts a C-compatible array (`CArray`) into a heap-allocated `Value`.
///
/// # Parameters
/// - `c_arr`: Pointer to a `CArray`.
///
/// # Returns
/// - A pointer to a heap-allocated `Value` containing the array data.
/// - Returns `null` if the input pointer is null or conversion fails.
///
/// # Safety
/// - `c_arr` must be a valid pointer returned from FFI or null.
/// - The returned pointer must be freed with `value_free` to avoid memory leaks.
/// - Ownership of the array memory is transferred temporarily; the original `CArray` should not be used after this call.
pub extern "C"
/// Converts a heap-allocated `Value` containing an array into a C-compatible `CArray`.
///
/// # Parameters
/// - `val`: Pointer to a `Value`.
///
/// # Returns
/// - A pointer to a heap-allocated `CArray` containing the array data.
/// - Returns `null` if the input pointer is null or the `Value` is not an array.
///
/// # Safety
/// - `val` must be a valid pointer returned from FFI or null.
/// - The returned `CArray` must be freed with `free_c_array` to avoid memory leaks.
/// - The memory inside `Value` remains managed by Rust; this only exposes the array contents as a `CArray`.
pub extern "C"