Deutsch English Français Italiano |
<20240310100715.866@kylheku.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: Kaz Kylheku <433-929-6894@kylheku.com> Newsgroups: comp.lang.c Subject: Re: avoiding strdup() Date: Sun, 10 Mar 2024 17:12:42 -0000 (UTC) Organization: A noiseless patient Spider Lines: 28 Message-ID: <20240310100715.866@kylheku.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> <20240310101101.00001fd4@yahoo.com> Injection-Date: Sun, 10 Mar 2024 17:12:42 -0000 (UTC) Injection-Info: dont-email.me; posting-host="ee7bdc3293676d3017c029b03873f9fc"; logging-data="3233986"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+F6Yl4wlnkElQmfe69Ou4wlSyAexghSgs=" User-Agent: slrn/pre1.0.4-9 (Linux) Cancel-Lock: sha1:+MyYlpQQjYfi6UhyBu/hxU+lT6Y= Bytes: 2129 On 2024-03-10, Michael S <already5chosen@yahoo.com> wrote: > On Sat, 09 Mar 2024 16:37:19 -0800 > Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote: >> strdup() and strndup() are being added to the C23 standard. >> > > What is justification? strdup is required by POSIX already and thus widely implemented. Many programmers who are not into standards already assume it's in C. For decades, portable programs have been doing things like this: #if HAVE_STRDUP #define xstrdup(s) strdup(s) #else char *xstrdup(const char *); // own definition #endif > What strdup() can do better, for any chosen value of better, than > strlen()+malloc()+memcpy() ? Not take up space in every application for a common library routine. -- TXR Programming Language: http://nongnu.org/txr Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal Mastodon: @Kazinator@mstdn.ca