From: Olivier Andrieu <oandrieu@nerim.net>
To: "Bauer, Christoph" <Christoph.Bauer@lms-gmbh.de>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Again C-Interface: caml_alloc_custom
Date: Fri, 20 Jan 2006 16:27:01 +0100 [thread overview]
Message-ID: <17361.325.830020.552502@karryall.dnsalias.org> (raw)
In-Reply-To: <26EB47FDD566A7469FC862DAF373792F07D738@kaiserslautern1.lmsintl.com>
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
prev parent reply other threads:[~2006-01-20 15:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-20 15:07 Bauer, Christoph
2006-01-20 15:27 ` Olivier Andrieu [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=17361.325.830020.552502@karryall.dnsalias.org \
--to=oandrieu@nerim.net \
--cc=Christoph.Bauer@lms-gmbh.de \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox