Skip to content

Commit 96e1ac3

Browse files
authored
Merge pull request #750 from yallop/clarify-string-view-documentation
Clarify the caveats about 'string' in the documentation.
2 parents 13f06c2 + 05f0435 commit 96e1ac3

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/ctypes/ctypes_types.mli

+13-4
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,19 @@ sig
193193
{!string} are copied into immovable C-managed storage before being passed
194194
to C.
195195
196-
When the memory is not owned by the C code, -- i.e. when creating or
197-
initializing a struct in OCaml before passing it to C -- then the
198-
{!string} view isn't a good choice, because there's no way to manage the
199-
lifetime of the C copy of the generated OCaml string.
196+
The string type representation is suitable for use in function argument
197+
types such as the following:
198+
199+
[string @-> returning int]
200+
201+
where the lifetime of the C-managed storage does not need to extend beyond
202+
the duration of the function call. However, it is not suitable for
203+
use in struct or union fields
204+
205+
[field s "x" string]
206+
207+
because it does not provide a way to manage the lifetime of the
208+
C-managed storage.
200209
*)
201210

202211
val string_opt : string option typ

0 commit comments

Comments
 (0)