From: Kaspar Rohrer <krohrer@student.ethz.ch>
To: caml-list@yquem.inria.fr
Subject: FFI: Allocating an array of doubles and initializing it
Date: Wed, 20 Jun 2007 04:47:15 +0200 [thread overview]
Message-ID: <47EE749E-06C8-4A20-8D38-EE47D43CBCA6@student.ethz.ch> (raw)
Hello,
I'm currently trying to allocate an array of doubles to pass some
values back to Ocaml. However, documentation on this specific topic
seems relatively sparse, and thus I'm not sure if the following is
correct:
CAMLprim value ml_create_float_array (value n, value fill)
{
CAMLparam2(n, fill);
CAMLlocal1(arr);
long i;
long N = Long_val(n);
double D = Double_val(fill);
arr = caml_alloc_shr(N * Double_wosize, Double_array_tag);
for (i = 0; i < N; ++i) {
Store_double_field(arr, i, D);
}
CAMLreturn(arr);
}
Any help appreciated.
Kaspar Rohrer
PS: I'm using Ocaml 3.09.
next reply other threads:[~2007-06-20 2:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-20 2:47 Kaspar Rohrer [this message]
2007-06-20 7:13 ` [Caml-list] " Olivier Andrieu
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=47EE749E-06C8-4A20-8D38-EE47D43CBCA6@student.ethz.ch \
--to=krohrer@student.ethz.ch \
--cc=caml-list@yquem.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