Deutsch English Français Italiano |
<AvZ1AG=nEY26QTs5J@bongo-ra.co> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!3.eu.feeder.erje.net!feeder.erje.net!paganini.bofh.team!not-for-mail From: Spiros Bousbouras <spibou@gmail.com> 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: <AvZ1AG=nEY26QTs5J@bongo-ra.co> 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; 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 <vallor@cultnix.org> 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.