unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: Andy Wingo <wingo@igalia.com>
Cc: guile-devel@gnu.org
Subject: Re: [PATCH] Avoid malloc/free/dynwind for POSIX subrs that take strings
Date: Fri, 22 May 2020 22:47:20 +0200	[thread overview]
Message-ID: <87d06v8zon.fsf@gnu.org> (raw)
In-Reply-To: <87ftbxwxco.fsf@igalia.com> (Andy Wingo's message of "Mon, 18 May 2020 08:50:15 +0200")

Hi!

Andy Wingo <wingo@igalia.com> skribis:

> On Sun 17 May 2020 23:46, Ludovic Courtès <ludo@gnu.org> writes:
>
>> The libunistring functions can take a pre-allocated buffer, but they
>> always malloc a fresh one if needed.  So the best we could do is have a
>> ‘scm_to_stringn’ variant that takes a buffer, but it’s not guaranteed
>> that it’ll actually be used.  All in all, it seems the added complexity
>> is not warranted.  The worst case of ‘scm_locale_string_data’ is also
>> rare enough.
>>
>> Thoughts?
>
> Interesting.  Probably we want to make a public
> scm_to_{,locale_,utf8_}gc_string{,n} API and use that as a fallback.
> GC-managed character buffers are less error-prone and probably just as
> fast.

Yeah.

> We can mostly avoid the double-copy by inline conversions, as we do with
> UTF-8.  For narrow strings scm_to_gc_stringn can always run iconv in a
> mode that just calculates output byte size; surely equivalent
> functionality is available from unistring, also.

Like I wrote, libunistring functions always malloc if the provided
buffer is not large enough to hold the converted string.  So we can’t
really ensure there won’t be any malloc.

Anyway, I’m putting this on hold for now!

Thanks,
Ludo’.



      reply	other threads:[~2020-05-22 20:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-29 20:22 [PATCH] Avoid malloc/free/dynwind for POSIX subrs that take strings Ludovic Courtès
2020-05-05  7:23 ` Andy Wingo
2020-05-17 21:46   ` Ludovic Courtès
2020-05-18  6:50     ` Andy Wingo
2020-05-22 20:47       ` Ludovic Courtès [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

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87d06v8zon.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=guile-devel@gnu.org \
    --cc=wingo@igalia.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 read-only IMAP folder(s) and NNTP newsgroup(s).