From: Vivien Kraus <vivien@planete-kraus.eu>
To: noloader@gmail.com, Bruno Haible <bruno@clisp.org>
Cc: bug-gnulib@gnu.org
Subject: Re: RFC: add a string-desc module
Date: Sat, 25 Mar 2023 07:25:20 +0100 [thread overview]
Message-ID: <e00edf9941567eb1e9fcf47da7ee2157ac0e8b36.camel@planete-kraus.eu> (raw)
In-Reply-To: <CAH8yC8mfviFog+wASgUsr7Te59WKxKF=xAeajY=K5OeMk6GRrg@mail.gmail.com>
Le vendredi 24 mars 2023 à 19:20 -0400, Jeffrey Walton a écrit :
> The type that I'm proposing does not have NUL byte appended to the
> data
> > always and automatically, because I think it is more important to
> > have a
> > string_desc_substring function that does not cause memory
> > allocation,
> > than to have string_desc_c function (conversion to 'char *') that
> > does
> > not cause memory allocation.
>
> I would take caution if not including a NULL. A natural thing to want
> to do is print a string, and C-based routines usually expect a
> terminating NULL.
>
> Also, if you initialize the struct, then the allocated string will
> likely include a terminating NULL. I understand the size member will
> omit the NULL, but it will be present anyways in the string. (Unless
> you do something ugly, like spell out the characters of the string).
From what I understand, the proposed substring function cannot add a
NUL byte without doing a copy first.
Vivien
next prev parent reply other threads:[~2023-03-25 11:52 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-24 21:50 RFC: add a string-desc module Bruno Haible
2023-03-24 22:32 ` Paul Eggert
2023-03-25 11:39 ` Bruno Haible
2023-03-24 23:20 ` Jeffrey Walton
2023-03-25 6:25 ` Vivien Kraus [this message]
2023-03-25 11:49 ` Bruno Haible
2023-03-25 15:51 ` Paul Eggert
2023-03-28 22:40 ` Bruno Haible
2023-03-25 6:21 ` Vivien Kraus
2023-03-25 11:56 ` Bruno Haible
2023-03-27 10:15 ` Simon Josefsson via Gnulib discussion list
2023-03-28 22:49 ` Bruno Haible
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://lists.gnu.org/mailman/listinfo/bug-gnulib
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e00edf9941567eb1e9fcf47da7ee2157ac0e8b36.camel@planete-kraus.eu \
--to=vivien@planete-kraus.eu \
--cc=bruno@clisp.org \
--cc=bug-gnulib@gnu.org \
--cc=noloader@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 read-only IMAP folder(s) and NNTP newsgroup(s).