Path: ...!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!bluemanedhawk.eternal-september.org!.POSTED!not-for-mail From: Blue-Maned_Hawk Newsgroups: comp.lang.c Subject: Re: avoiding strdup() Date: Sun, 10 Mar 2024 13:38:48 -0000 (UTC) Organization: A noiseless patient Spider Lines: 14 Message-ID: References: <87y1ayj6hs.fsf_-_@bsb.me.uk> <87r0gizzuo.fsf@nosuchdomain.example.com> <20240310101101.00001fd4@yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Sun, 10 Mar 2024 13:38:48 -0000 (UTC) Injection-Info: bluemanedhawk.eternal-september.org; posting-host="19bb270a84962846e11be7f5fbeb47d2"; logging-data="3142983"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/EyylU4//yNHeefuFxFO1+B4DS+Zq4x3I=" User-Agent: Pan/0.154 (Izium; 517acf4) Cancel-Lock: sha1:fbf1XbNCSkyfUYaiXkUONiVmfEM= X-Face: =?UTF-8?B?TGxhbmZhaXLDg8KDwoPCg8KDwoPCgsODwoPCg8KDwoPCgsODwoPCg8KDwoLDg8KDwoPCgsODwoPCgsODwoLDgg==?= =?UTF-8?B?IMKtcHdsbGd3eW5neWxsw4PCg8KDwoPCg8KDwoLDg8KDwoPCg8KDwoLDg8KDwoPCg8KCw4PCg8KDwoLDg8KDwoLDgw==?= =?UTF-8?B?woLDgg==?= =?UTF-8?B?wiCtZ29nZXJ5w4PCg8KDwoPCg8KDwoLDg8KDwoPCg8KDwoLDg8KDwoPCg8KCw4PCg8KDwoLDg8KDwoLDg8KCw4LCrWNod3k=?= =?us-ascii?Q?rn?= =?UTF-8?B?IMODwoPCg8KDwoPCg8KCw4PCg8KDwoPCg8KCw4PCg8KDwoPCgsODwoPCg8KCw4PCg8KCw4PCgsOCwq1kcm9id2xsw4PCg8KD?= =?UTF-8?B?IMKDwoPCg8KCw4PCg8KDwoPCg8KCw4PC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ZxZVMcjefoK2J0gUY2S3rxz/RuTFx 2zHd9U+obimJXMG4edsk/2j5pTU5G1MmzbRLxkfq5EiT1GGsidvMGzi+1goGb2l GCrN+nGnV8xj3q3JLRDVPL96vUc7Z4aJ3TN1mVqWAMJMfG+Jxh6TQqP+92iZkCU xtglds1AB6r0aiSHKcnFck+p/c/0CbacFLQcajGcAAAAASUVORK5CYII= Bytes: 3598 Michael S wrote: > What strdup() can do better, for any chosen value of better, than > strlen()+malloc()+memcpy() ? It's shorter. -- Blue-Maned_Hawk│shortens to Hawk│/blu.mɛin.dʰak/│he/him/his/himself/Mr. blue-maned_hawk.srht.site The logical conclusion of “don't repeat yourself” is to never say anything.