caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Gabriel Scherer <gabriel.scherer@gmail.com>
To: "Richard W.M. Jones" <rich@annexia.org>
Cc: immanuel litzroth <ilitzroth@gmail.com>,
	OCaML List Mailing <caml-list@inria.fr>
Subject: Re: [Caml-list] Raising invalid_argument with a constructed string.
Date: Sat, 3 Dec 2016 14:44:10 -0500	[thread overview]
Message-ID: <CAPFanBFw4QAkDBA4NkfhTCO+oia3ut8uVg00kVOZejjufoZpcg@mail.gmail.com> (raw)
In-Reply-To: <20161203193624.GB28111@annexia.org>

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

I guess I'm not modern enough to feel comfortable using alloca (or
variable-length arrays) in my code :-)

On Sat, Dec 3, 2016 at 2:36 PM, Richard W.M. Jones <rich@annexia.org> wrote:

> On Sat, Dec 03, 2016 at 03:00:57PM +0100, immanuel litzroth wrote:
> > Yes, I've used that solution too, keeping a static fixed string around,
> > it's just not very nice and will break if it's ever multithreaded.
>
> You shouldn't make the string static, and we do *not* do that in
> libguestfs.  You should simply allocate it on the stack.  This is
> thread safe.
>
> Also on the bug it was stated:
>
> > The stack-based solutions rely on guessing arbitrary size limits on
> > the dynamic strings, which is often possibles but sometimes
> > inconvenient/inelegant.
>
> but this is not true either.  You can use alloca to allocate a
> variable sized string on the stack.
>
> As Xavier Leroy says, fixing this is not necessary, although there's
> perhaps a usability argument.
>
> Rich.
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa.inria.fr/sympa/arc/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: 2019 bytes --]

      reply	other threads:[~2016-12-03 19:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-28 14:39 immanuel litzroth
2016-11-28 15:43 ` David Allsopp
2016-11-28 15:50   ` Gabriel Scherer
2016-11-29 10:21     ` immanuel litzroth
2016-12-03 13:20 ` Richard W.M. Jones
2016-12-03 14:00   ` immanuel litzroth
2016-12-03 19:36     ` Richard W.M. Jones
2016-12-03 19:44       ` Gabriel Scherer [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=CAPFanBFw4QAkDBA4NkfhTCO+oia3ut8uVg00kVOZejjufoZpcg@mail.gmail.com \
    --to=gabriel.scherer@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=ilitzroth@gmail.com \
    --cc=rich@annexia.org \
    /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).