[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Jean-Marc EBER <jeanmarc.eber@l...> |
| Subject: | question about the OCaml/C interface |
Hello to all,
I have a little technical question about the OCaml/C interface:
Is the following code "correct":
CAMLprim value my_func(...)
{
CAMLlocal2(ret);
...
result = ...
ret = caml_alloc(5, 0);
Store_field(ret, 0, caml_copy_double(result));
...
CAMLreturn (ret);
}
or, arguing that [caml_copy_double] allocates and may therfore launch a gc cycle
that may therefore modify [ret], one must write:
CAMLprim value my_func(...)
{
...
CAMLlocal2(v, ret);
...
result = ...
ret = caml_alloc(5, 0);
v = caml_copy_double(result);
Store_field(ret, 0, v);
...
CAMLreturn (ret);
}
I don't find a clear answer to that question in the documentation.
Jean-Marc Eber