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
64
use crateValue;
use crateCArray;
/// Converts a C-compatible array (`CArray`) into a heap-allocated [`Value`].
///
/// # Parameters
/// - `c_arr`: Pointer to a `CArray` containing array elements.
///
/// # Returns
/// - A raw pointer to a heap-allocated [`Value`] containing the array data.
/// - Returns `null` if the input pointer is null or the conversion fails.
///
/// # Safety
/// - `c_arr` must be a valid pointer or null.
/// - The caller must free the returned pointer 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`] expected to contain an array.
///
/// # Returns
/// - A raw 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 or null.
/// - The returned `CArray` must be freed with `free_c_array` to avoid memory leaks.
/// - Memory inside the original [`Value`] remains managed by Rust; this exposes the array contents as a `CArray`.
pub extern "C"