Warning: mysqli::__construct(): (HY000/1203): User howardkn already has more than 'max_user_connections' active connections in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\includes\artfuncs.php on line 21
Failed to connect to MySQL: (1203) User howardkn already has more than 'max_user_connections' active connections
Warning: mysqli::query(): Couldn't fetch mysqli in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\index.php on line 66
Article <20240310101101.00001fd4@yahoo.com>
Deutsch   English   Français   Italiano  
<20240310101101.00001fd4@yahoo.com>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Michael S <already5chosen@yahoo.com>
Newsgroups: comp.lang.c
Subject: Re: avoiding strdup()
Date: Sun, 10 Mar 2024 10:11:01 +0200
Organization: A noiseless patient Spider
Lines: 44
Message-ID: <20240310101101.00001fd4@yahoo.com>
References: <us0brl$246bf$1@dont-email.me>
	<pan$4fc39$61bdfbef$3ca9a71a$af842694@invalid.invalid>
	<87y1ayj6hs.fsf_-_@bsb.me.uk>
	<pan$e9f7e$d6f7a386$31c353e8$a08c13cf@invalid.invalid>
	<usc845$10v6e$1@dont-email.me>
	<pan$89aca$33d2df8c$9e2c232f$d767db40@invalid.invalid>
	<ushea7$28prq$2@dont-email.me>
	<ushnkb$1rnlb$4@dont-email.me>
	<87r0gizzuo.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="a901402e370eaa30848be77995d92c68";
	logging-data="1078572"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19RW1X3YeBkV1VjHWzQpUQfcw6oK39AqwM="
Cancel-Lock: sha1:eGG5PgYv1vzKJOpaSvwolssUtc0=
X-Newsreader: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-w64-mingw32)
Bytes: 2761

On Sat, 09 Mar 2024 16:37:19 -0800
Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:

> vallor <vallor@cultnix.org> writes:
> [...]
> > Meanwhile, saw someone in another group write:
> >
> > char * something;
> > something = strdup("writable string etc.");
> > if( something == NULL ) { etc. }
> >
> > But that won't work if --std=c99, does work for g99 and c2x.
> > The (Linux) man page says:
> > /* Since glibc 2.12: */ _POSIX_C_SOURCE >= 200809L
> >
> > I asked Google about it being a POSIX extension
> > added at that late date, and it gave me an answer
> > about the C standard:
> >
> > "C9X London meeting update"
> > https://groups.google.com/g/comp.std.c/c/pMaEU_8Rb7w
> >  _ _ _ _ _
> > 2. strsep and strdup are not being added. strsep() is out because
> > not enough people wanted it to vote it in; strdup() lost on the
> > grounds that it would be the *ONLY* function other than *alloc()
> > in the entire library whose return could be sanely passed to free(),
> > and this is surprising.
> >  _ _ _ _ _
> >
> > Also:
> > <https://stackoverflow.com/questions/32944390/what-is-the-rationale-
> > for-not-including-strdup-in-the-c-standard>
> >
> > Anyway, pointed out that they can just use an initializer, something
> > about which I was clued in by a friendly person in this very group.
> >  
> 
> strdup() and strndup() are being added to the C23 standard.
> 

What is justification?
What strdup() can do better, for any chosen value of better, than
strlen()+malloc()+memcpy() ?