From: "Alexandre François Garreau" <galex-713@galex-713.eu>
To: libc-help@sourceware.org
Subject: malloc’ing strcat
Date: Mon, 24 Feb 2020 02:58:00 -0000 [thread overview]
Message-ID: <25950016.Ncol2qhMyO@galex-713.eu> (raw)
Hi,
strcat needs a buffer already wide enough to contain concatenation of both
strings, hence I deduce idiomatic use is to first malloc(strlen(str1) +
strlen(str2) + 1)…
But then the usage must always be something like:
#define strcat(a, b) strcat (strcpy (malloc (strlen(a) + strlen (b) + 1)
a), b)
(which, of course, requires further free())…
So is there already a function or macro which does that? if not so, why?
asprintf&cie already exist, after all…
next reply other threads:[~2020-02-24 2:58 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-24 2:58 Alexandre François Garreau [this message]
2020-02-24 11:17 ` Florian Weimer
2020-02-24 12:31 ` Alexandre François Garreau
2020-02-24 12:38 ` Florian Weimer
2020-02-24 20:23 ` Alexandre François Garreau
2020-02-24 21:17 ` Florian Weimer
2020-02-25 3:58 ` Alexandre François Garreau
2020-02-25 9:41 ` Florian Weimer
2020-02-25 12:48 ` Alexandre François Garreau
2020-02-25 12:53 ` Florian Weimer
2020-02-25 13:04 ` Alexandre François Garreau
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=25950016.Ncol2qhMyO@galex-713.eu \
--to=galex-713@galex-713.eu \
--cc=libc-help@sourceware.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 read-only IMAP folder(s) and NNTP newsgroup(s).