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 <87r0gizzuo.fsf@nosuchdomain.example.com>
Deutsch   English   Français   Italiano  
<87r0gizzuo.fsf@nosuchdomain.example.com>

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

Path: ...!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith Thompson <Keith.S.Thompson+u@gmail.com>
Newsgroups: comp.lang.c
Subject: Re: avoiding strdup()
Date: Sat, 09 Mar 2024 16:37:19 -0800
Organization: None to speak of
Lines: 38
Message-ID: <87r0gizzuo.fsf@nosuchdomain.example.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>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="18a65937555f48f1385aec071e6a1095";
	logging-data="2735058"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/ndM3i4o1vSzycPSr5IhHV"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:DKVskR5bdXT5TW+xlN6mUIL19S0=
	sha1:Z8HOBfP4UYEOmHZ5ltIuOcRU5fE=
Bytes: 2600

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.

-- 
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Medtronic
void Void(void) { Void(); } /* The recursive call of the void */