[
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: | Olivier Andrieu <oandrieu@n...> |
| Subject: | Re: [Caml-list] Again C-Interface: caml_alloc_custom |
Bauer, Christoph [Friday 20 January 2006] :
> Could be here a problem (CAMLparam+CAMLreturn in C-called function):
>
> static value copy_tcl_array(int objc, Tcl_Obj * const * objv)
> {
> CAMLparam0 ();
> CAMLlocal2 (result, t);
> int n;
>
> result = Val_int(0);
> for (n = objc-1; n >= 0; --n) {
> t = caml_alloc_small(2,0);
> Field(t, 0) = alloc_tcl_obj( objv[n] );
^^^^^^^^^^^^^
I guess alloc_tcl_obj creates the custom block. That's wrong because
the block t you've just allocated with caml_alloc_small is not
completely initialized yet.
Either do this (safe, higher-level way):
,----
| t = caml_alloc (2, 0);
| Store_field (t, 0, alloc_tcl_obj (objv[n]));
| Store_field (t, 1, result);
`----
or that (lower-level) :
,----
| CAMLlocal1(obj);
| obj = alloc_tcl_obj (objv[n]);
| t = caml_alloc_small (2, 0);
| Field (t, 0) = obj;
| Field (t, 1) = result;
`----
--
Olivier