caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Stephane Glondu <steph@glondu.net>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Runtime string allocation/resizing
Date: Tue, 21 Jun 2005 14:49:26 -0700	[thread overview]
Message-ID: <200506211449.27483.steph@glondu.net> (raw)
In-Reply-To: <42B87C09.3020008@rftp.com>

On Tuesday 21 June 2005 13:43, Robert Roessler wrote:
> [...]
>
> What is the recommended "OCaml" way to deal with this?
>
> Should I do two caml_alloc_string calls?  One to initially "get" the
> data, and then alloc a second one and copy to it after I know the
> correct length?
>
> Or would it be considered better practice to use malloc in the C heap
> for the "temp" copy and only do the caml_alloc_string when I know the
> exact size?

The second one is clearly better since the temp copy won't be used by the 
OCaml part. However, maybe there is a better alternative (for example, 
directly allocating in OCaml heap, then setting the string length so that the 
"extra" part is ignored).

Stephane Glondu.


  reply	other threads:[~2005-06-21 21:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-21 20:43 Robert Roessler
2005-06-21 21:49 ` Stephane Glondu [this message]
2005-06-22  0:07 ` [Caml-list] " Jacques Garrigue

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=200506211449.27483.steph@glondu.net \
    --to=steph@glondu.net \
    --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;
as well as URLs for NNTP newsgroup(s).