Path: ...!3.eu.feeder.erje.net!feeder.erje.net!paganini.bofh.team!not-for-mail From: Spiros Bousbouras Newsgroups: comp.lang.c Subject: Re: avoiding strdup() Date: Sat, 9 Mar 2024 15:25:03 -0000 (UTC) Organization: To protect and to server Message-ID: References: <87y1ayj6hs.fsf_-_@bsb.me.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Injection-Date: Sat, 9 Mar 2024 15:25:03 -0000 (UTC) Injection-Info: paganini.bofh.team; logging-data="2837160"; posting-host="9H7U5kayiTdk7VIdYU44Rw.user.paganini.bofh.team"; mail-complaints-to="usenet@bofh.team"; posting-account="9dIQLXBM7WM9KzA+yjdR4A"; Cancel-Lock: sha256:BF4TEf4yCe7EwnAbZdDlmrWKHMX5XBgnKmsDgLLGLlY= X-Server-Commands: nowebcancel X-Organisation: Weyland-Yutani X-Notice: Filtered by postfilter v. 0.9.3 Bytes: 2260 Lines: 26 On Sat, 9 Mar 2024 13:19:07 -0000 (UTC) vallor wrote: > 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. The design of strsep() is poor. The reasoning for not adding strdup() doesn't make any sense to me.