From: Daniel de Rauglaudre <daniel.de_rauglaudre@inria.fr>
To: Harry Chomsky <harry@chomsky.net>
Cc: Caml list <caml-list@inria.fr>
Subject: Re: [Caml-list] Win32 API
Date: Fri, 1 Jun 2001 00:13:01 +0200 [thread overview]
Message-ID: <20010601001301.A11836@verdot.inria.fr> (raw)
In-Reply-To: <00c301c0ea11$17a38570$22f65140@w2kpro>; from harry@chomsky.net on Thu, May 31, 2001 at 01:34:29PM -0700
Hi,
On Thu, May 31, 2001 at 01:34:29PM -0700, Harry Chomsky wrote:
> I've embarked on a project to enable writing full-fledged Win32 applications
> using OCaml. I'm doing this mostly for fun as I take a break between jobs.
> [...]
> http://www.speakeasy.org/~hchomsky/ocaml-win32.html
> [...]
> The main area I'm uncomfortable with is memory management and the section of
> [...]
As far as I read your C code, you are likely to have problems with the
OCaml GC: you risk unexpected Memory Faults or Bus Errors. When you
call an OCaml alloc function, all your variables of type "value" may
point to wrong places. E.g. if you write:
some_function (value x)
{
value y;
y = alloc_tuple(2);
...
}
The "alloc_tuple" may call the GC: and the GC may move the other OCaml
allocated values. If the parameter x corresponds to a pointer (i.e. not
an integer), its value may become false after the allocation of y (may
or may not). The correct way is to previously inform the GC that it
has to change the value of the variable x if it changes the location
of the values it refers to.
This can (must) be done by the macros defined in the module memory.h.
The correct way (if I am not wrong) to write this function like this:
some_function (value x)
{
CAMLparam1(x);
value y;
y = alloc_tuple(2);
...
}
--
Daniel de RAUGLAUDRE
daniel.de_rauglaudre@inria.fr
http://cristal.inria.fr/~ddr/
-------------------
To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr
next prev parent reply other threads:[~2001-05-31 22:13 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-05-31 20:34 Harry Chomsky
2001-05-31 22:13 ` Daniel de Rauglaudre [this message]
2001-05-31 22:59 ` Harry Chomsky
2001-06-01 11:48 ` Daniel de Rauglaudre
2001-06-04 4:01 ` Harry Chomsky
2001-06-04 4:49 ` Daniel de Rauglaudre
2001-06-04 8:53 ` Stefan Monnier
2001-06-02 14:56 ` Dmitry Bely
2001-12-31 20:52 Harry Chomsky
2002-01-01 18:22 ` Warp
2002-01-02 4:56 ` Harry Chomsky
2002-01-02 20:27 ` Warp
2002-01-12 21:37 ` Harry Chomsky
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=20010601001301.A11836@verdot.inria.fr \
--to=daniel.de_rauglaudre@inria.fr \
--cc=caml-list@inria.fr \
--cc=harry@chomsky.net \
/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