caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] C bindings and Gc.compact
@ 2011-04-05 11:27 Pedro Borges
  2011-04-05 12:52 ` [Caml-list] " Sylvain Le Gall
  2011-04-05 15:03 ` [Caml-list] " Niki Yoshiuchi
  0 siblings, 2 replies; 3+ messages in thread
From: Pedro Borges @ 2011-04-05 11:27 UTC (permalink / raw)
  To: caml-list

Hi, everyone,

If a compactification is triggered do the values get rewritten or do
they become invalid?


Best Regards,

Pedro Borges

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Caml-list] Re: C bindings and Gc.compact
  2011-04-05 11:27 [Caml-list] C bindings and Gc.compact Pedro Borges
@ 2011-04-05 12:52 ` Sylvain Le Gall
  2011-04-05 15:03 ` [Caml-list] " Niki Yoshiuchi
  1 sibling, 0 replies; 3+ messages in thread
From: Sylvain Le Gall @ 2011-04-05 12:52 UTC (permalink / raw)
  To: caml-list

Hello,

On 05-04-2011, Pedro Borges <pdhb.lists@gmail.com> wrote:
> Hi, everyone,
>
> If a compactification is triggered do the values get rewritten or do
> they become invalid?
>
>

If the value have been allocated outside the Gc (e.g. malloc-ed), the
pointer is still valid. If it is an OCaml value, it will get rewritten.
But this is already the case with the other Gc stage, and the reason why
you should use CAMLparam/CAMLreturn.

Cheers,
Sylvain Le Gall
-- 
My company: http://www.ocamlcore.com
Linkedin:   http://fr.linkedin.com/in/sylvainlegall
Start an OCaml project here: http://forge.ocamlcore.org
OCaml blogs:                 http://planet.ocamlcore.org



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] C bindings and Gc.compact
  2011-04-05 11:27 [Caml-list] C bindings and Gc.compact Pedro Borges
  2011-04-05 12:52 ` [Caml-list] " Sylvain Le Gall
@ 2011-04-05 15:03 ` Niki Yoshiuchi
  1 sibling, 0 replies; 3+ messages in thread
From: Niki Yoshiuchi @ 2011-04-05 15:03 UTC (permalink / raw)
  To: Pedro Borges; +Cc: caml-list

[-- Attachment #1: Type: text/plain, Size: 936 bytes --]

The manual has a section on just this issue, although the manual can be a
little confusing at times:
http://caml.inria.fr/pub/docs/manual-ocaml/manual032.html#toc140

Sylvain Le Gall already mentioned the basics - registering the values with
the garbage collector using CAMLparam (and then releasing them with
CAMLreturn) prevents any problems.  Also local values should be declared
using CAMLlocal and global values should be registered using
caml_global_register_root.

On Tue, Apr 5, 2011 at 7:27 AM, Pedro Borges <pdhb.lists@gmail.com> wrote:

> Hi, everyone,
>
> If a compactification is triggered do the values get rewritten or do
> they become invalid?
>
>
> Best Regards,
>
> Pedro Borges
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa-roc.inria.fr/wws/info/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
>

[-- Attachment #2: Type: text/html, Size: 1589 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-04-05 15:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-05 11:27 [Caml-list] C bindings and Gc.compact Pedro Borges
2011-04-05 12:52 ` [Caml-list] " Sylvain Le Gall
2011-04-05 15:03 ` [Caml-list] " Niki Yoshiuchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).