@@ -115,11 +115,14 @@ getindex(collection, key...)
115
115
"""
116
116
cconvert(T,x)
117
117
118
- Convert `x` to a value of type `T`, typically by calling `convert(T,x)`
118
+ Convert `x` to a value to be passed to C code as type `T`, typically by calling `convert(T, x)`.
119
119
120
120
In cases where `x` cannot be safely converted to `T`, unlike [`convert`](@ref), `cconvert` may
121
121
return an object of a type different from `T`, which however is suitable for
122
- [`unsafe_convert`](@ref) to handle.
122
+ [`unsafe_convert`](@ref) to handle. The result of this function should be kept valid (for the GC)
123
+ until the result of [`unsafe_convert`](@ref) is not needed anymore.
124
+ This can be used to allocate memory that will be accessed by the `ccall`.
125
+ If multiple objects need to be allocated, a tuple of the objects can be used as return value.
123
126
124
127
Neither `convert` nor `cconvert` should take a Julia object and turn it into a `Ptr`.
125
128
"""
@@ -881,7 +884,8 @@ trunc
881
884
"""
882
885
unsafe_convert(T,x)
883
886
884
- Convert `x` to a value of type `T`
887
+ Convert `x` to a C argument of type `T`
888
+ where the input `x` must be the return value of `cconvert(T, ...)`.
885
889
886
890
In cases where [`convert`](@ref) would need to take a Julia object
887
891
and turn it into a `Ptr`, this function should be used to define and perform
@@ -895,6 +899,8 @@ but `x=[a,b,c]` is not.
895
899
The `unsafe` prefix on this function indicates that using the result of this function after
896
900
the `x` argument to this function is no longer accessible to the program may cause undefined
897
901
behavior, including program corruption or segfaults, at any later time.
902
+
903
+ See also [`cconvert`](@ref)
898
904
"""
899
905
unsafe_convert
900
906
0 commit comments