From: Robert Roessler <roessler@rftp.com>
To: Caml-list <caml-list@inria.fr>
Subject: Runtime string allocation/resizing
Date: Tue, 21 Jun 2005 13:43:53 -0700 [thread overview]
Message-ID: <42B87C09.3020008@rftp.com> (raw)
When dealing with OCaml-to-C-land interfacing, I sometimes am in the
position of needing to allocate and fill a string - but only have an
upper bound for the length... until after I have already copied the
data [from a third-party library function].
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?
Or ?
BTW, I am more concerned with longer-term issues like memory
fragmentation and "extra" [minor] collections than with raw speed (as
in copying the data twice being "evil").
Robert Roessler
roessler@rftp.com
http://www.rftp.com
next reply other threads:[~2005-06-21 20:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-06-21 20:43 Robert Roessler [this message]
2005-06-21 21:49 ` [Caml-list] " Stephane Glondu
2005-06-22 0:07 ` 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=42B87C09.3020008@rftp.com \
--to=roessler@rftp.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