caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Anatoly Zaretsky" <anatoly.zaretsky@gmail.com>
To: "Jonathan Roewen" <jonathan.roewen@gmail.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] help with caml_stat_alloc
Date: Mon, 24 Jul 2006 14:39:30 +0300	[thread overview]
Message-ID: <a21cb60a0607240439l2b7dad8bj42d6ed8f3aad376@mail.gmail.com> (raw)
In-Reply-To: <73347253780-BeMail@beos>

On 7/24/06, Jonathan Roewen <jonathan.roewen@gmail.com> wrote:
> Hi,
>
> I'm trying to allocate some memory outside of the caml heap, and I
> think caml_stat_alloc is the right function to use. Anyways, it's
> generating seg-faults, so I'm hoping someone can help me fix my
> implementation.
>
> CAMLprim value icfp_alloc(value size) {
>         int sz = Int32_val(size) + 1;
>         int *p = (int *)caml_stat_alloc(sz);
>         p[--sz] = sz;
>         /*while ( sz > 0 ) {
>                 p[--sz] = 0;
>         }*/
>         return caml_copy_int32(p);
> }

>From byterun/memory.h:
CAMLextern void * caml_stat_alloc (asize_t);              /* Size in bytes. */

So p[--sz] is out of allocated region.

--
Tolik


      parent reply	other threads:[~2006-07-24 11:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-24  7:50 Jonathan Roewen
2006-07-24  8:56 ` Richard Jones
2006-07-24 10:13   ` Olivier Andrieu
2006-07-24 11:39 ` Anatoly Zaretsky [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=a21cb60a0607240439l2b7dad8bj42d6ed8f3aad376@mail.gmail.com \
    --to=anatoly.zaretsky@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=jonathan.roewen@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).