From: doligez@pa.dec.com
To: caml-list@inria.fr
Subject: Re: trouble with C pointers and GC
Date: Mon, 19 Apr 1999 11:50:19 -0700 [thread overview]
Message-ID: <199904191850.AA02045@neuf.pa.dec.com> (raw)
In-Reply-To: Message of Mon, 19 Apr 1999 16:42:30 +0200 from Patrick Goldbronn - SYSCO <patrick.goldbronn@cea.fr> <371B40D6.1760563E@cea.fr>
>From: Patrick Goldbronn - SYSCO <patrick.goldbronn@cea.fr>
> adr1 = (double *) calloc(nb1,sizeof(double));
> adr2 = (int *) calloc(nb2,sizeof(int));
>
>and I want to put it in a value with Final_tag :
>
> result = alloc_final( n , free_function , nb_elm*2 , 1 ) ;
^^^^^^^^^^^^
This doesn't look right: it will force a major GC every time, unless
nb_elm == 0.
>I don't know what is the value of n (n words) : A pointer value
>represent 1 word or 2 ?
A pointer is 1 word, and you must count the pointer to free_function,
so n would be 3.
>How can I store the pointers adr1 and adr2 in value result and how can I
>retrieve them (with Store_field and Field ?) ?
Since the pointer to free_function uses the first field, they would be
at offsets 1 and 2:
result = alloc_final (3, &free_function, 0, 1);
Store_field (result, 1, adr1);
Store_field (result, 2, adr2);
And to use them: "Field (result, 1)" and "Field (result, 2)".
-- Damien
prev parent reply other threads:[~1999-04-20 6:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <patrick.goldbronn@cea.fr>
1999-04-19 14:42 ` Patrick Goldbronn - SYSCO
1999-04-19 18:50 ` doligez [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=199904191850.AA02045@neuf.pa.dec.com \
--to=doligez@pa.dec.com \
--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