Deutsch   English   Français   Italiano  
<wwv7ci837oa.fsf@LkoBDZeT.terraraq.uk>

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

Path: ...!feeds.phibee-telecom.net!2.eu.feeder.erje.net!feeder.erje.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!news.gegeweb.eu!gegeweb.org!nntp.terraraq.uk!.POSTED.tunnel.sfere.anjou.terraraq.org.uk!not-for-mail
From: Richard Kettlewell <invalid@invalid.invalid>
Newsgroups: comp.lang.c
Subject: Re: avoiding strdup()
Date: Mon, 11 Mar 2024 19:11:33 +0000
Organization: terraraq NNTP server
Message-ID: <wwv7ci837oa.fsf@LkoBDZeT.terraraq.uk>
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> <20240310100715.866@kylheku.com>
	<ifnHN.386274$vFZa.250421@fx13.iad> <usnb64$3n297$1@dont-email.me>
	<yMGHN.481214$PuZ9.381006@fx11.iad> <20240311104527.444@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: innmantic.terraraq.uk; posting-host="tunnel.sfere.anjou.terraraq.org.uk:172.17.207.6";
	logging-data="19315"; mail-complaints-to="usenet@innmantic.terraraq.uk"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:StlCtbDup8xr2MCgIhJ6/Zj/wTQ=
X-Face: h[Hh-7npe<<b4/eW[]sat,I3O`t8A`(ej.H!F4\8|;ih)`7{@:A~/j1}gTt4e7-n*F?.Rl^
     F<\{jehn7.KrO{!7=:(@J~]<.[{>v9!1<qZY,{EJxg6?Er4Y7Ng2\Ft>Z&W?r\c.!4DXH5PWpga"ha
     +r0NzP?vnz:e/knOY)PI-
X-Boydie: NO
Bytes: 2726
Lines: 24

Kaz Kylheku <433-929-6894@kylheku.com> writes:
> Scott Lurndal <scott@slp53.sl.home> wrote:
>> Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:
>>>On 10/03/2024 18:47, Scott Lurndal wrote:
>>>> Kaz Kylheku <433-929-6894@kylheku.com> writes:
>>>>> Not take up space in every application for a common library routine.
>>>> 
>>>> It's a form of lazy programming.  I've seen a lot of open source
>>>> code that uses strdup without checking for failure and frequently
>>>> "forgetting" to free the result.
>>>
>>>And it is probably more likely that machine with many gigabytes of RAM 
>>
>> Actually, your assumptions that:
>>   1) strdup is the only allocation function used by an application
>>   2) all strings are "short"
>
> Even if a string is long enough to need its own mmap request,
> that will still return valid memory that later fails to commit.

Since strdup necessarily writes to almost all the memory it allocates,
you’d expect the failure to be immediate.

-- 
https://www.greenend.org.uk/rjk/