@@ -115,11 +115,14 @@ getindex(collection, key...)
115115"""
116116 cconvert(T,x)
117117
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)`.
119119
120120In cases where `x` cannot be safely converted to `T`, unlike [`convert`](@ref), `cconvert` may
121121return 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 object needs to be allocated, a tuple of the objects can be used as return value.
123126
124127Neither `convert` nor `cconvert` should take a Julia object and turn it into a `Ptr`.
125128"""
@@ -881,7 +884,7 @@ trunc
881884"""
882885 unsafe_convert(T,x)
883886
884- Convert `x` to a value of type `T`
887+ Convert `x` to a C argument of type `T` where `x` is the return value of `cconvert(T, ...)`.
885888
886889In cases where [`convert`](@ref) would need to take a Julia object
887890and turn it into a `Ptr`, this function should be used to define and perform
@@ -895,6 +898,8 @@ but `x=[a,b,c]` is not.
895898The `unsafe` prefix on this function indicates that using the result of this function after
896899the `x` argument to this function is no longer accessible to the program may cause undefined
897900behavior, including program corruption or segfaults, at any later time.
901+
902+ See also [`cconvert`](@ref)
898903"""
899904unsafe_convert
900905
0 commit comments