Deutsch English Français Italiano |
<87cyrz84l0.fsf@nosuchdomain.example.com> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson <Keith.S.Thompson+u@gmail.com> Newsgroups: comp.lang.c Subject: Re: avoiding strdup() Date: Tue, 12 Mar 2024 15:31:39 -0700 Organization: None to speak of Lines: 33 Message-ID: <87cyrz84l0.fsf@nosuchdomain.example.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> <20240310100715.866@kylheku.com> <ifnHN.386274$vFZa.250421@fx13.iad> <usnb64$3n297$1@dont-email.me> <yMGHN.481214$PuZ9.381006@fx11.iad> <usoa6a$3tqji$1@dont-email.me> <87sf0w8cux.fsf@nosuchdomain.example.com> <uspt19$c2he$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain Injection-Info: dont-email.me; posting-host="de8f53c78bf32f77c14d770a36ea4d62"; logging-data="574840"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19eOZidY1WRhgDdopEZATuq" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) Cancel-Lock: sha1:ymVuZS3FFhgU8xwwvVP+8SlKRww= sha1:hr2ZpGWlcTUJZ3qbGcreiHTXEfE= Bytes: 3085 Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes: > On 12/03/2024 01:20, Keith Thompson wrote: >> Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes: [...] >> If I withdraw 20 pounds from my bank, I'll bet you that 20 pounds >> that the bank still checks whether it has the money. I'd rather >> write correct code than code that almost certainly happens to work. >> Sure, strdup() is unlikely to fail-- but I'm going to check the >> result. >> >>> And how often do banks fail, actually, and how often does government >>> take action when it's heading that way, but nowhere near failing yet? >> The government isn't going to intervene when your laptop is running >> low on memory. >> > No, it's an analogy. You run lots of apps gobbling lots of memory, and > maybe a program won't launch or thngs start to slow or a warning comes > up, and you realise that soon the program of interest might run out of > memory, and so you shut other things down so that that doesn't happen. > And so it's pretty rare to actually run out of memory unless the > program isn't correct and there is a leak. Are you relying in a person sitting in front of the computer and noticing that memory is running low? The vast majority of software doesn't have someone watching it. I agree that an allocation failure in strdup() is unlikely. Are you suggesting that that means you needn't bother checking the result? -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com Working, but not speaking, for Medtronic void Void(void) { Void(); } /* The recursive call of the void */