Path: ...!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: David Brown Newsgroups: comp.lang.c Subject: Re: avoiding strdup() Date: Wed, 13 Mar 2024 16:08:02 +0100 Organization: A noiseless patient Spider Lines: 56 Message-ID: References: <87r0gizzuo.fsf@nosuchdomain.example.com> <20240310101101.00001fd4@yahoo.com> <20240310100715.866@kylheku.com> <87sf0w8cux.fsf@nosuchdomain.example.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Wed, 13 Mar 2024 15:08:02 -0000 (UTC) Injection-Info: dont-email.me; posting-host="48bdc0a10db3d8c077759fdca62ffe86"; logging-data="1067678"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/h3kx/v+gsy9kBKzrDH7ki1ohrvFi7/CQ=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Cancel-Lock: sha1:yLsaQpHiGGPwkpQckRVJVhu//cs= In-Reply-To: Content-Language: en-GB Bytes: 4206 On 13/03/2024 08:46, James Kuyper wrote: > On 3/12/24 19:50, Scott Lurndal wrote: >> Malcolm McLean writes: > ... >>> So 2,294 Americans in 1932 had the experience "you want to withdraw >>> cash? OK, here we go, oh sorry, that just took us over the edge and the >>> bank is now closed". Everyone else, either "here's your money", or >>> "sorry, the bank has now closed, no more withdrawal requests". >> >> I'm pretty sure the quote above from Wikipedia is written in >> a form of English that even the English understand, so I don't see >> how you came up with the idea that only 2,294 Americans were >> affected when 2,294 banks failed. > > Every bank fails at some particular time, when it runs out of money. > There is always one particular claim on that bank's resources that > caused it to run out and for some reason he's focusing on those claims. > Other Americans also had problems due to the bank having already failed, > but at most 2294 Americans made claims that actually triggered that > failure. I haven't a clue as to why he considers that fact important, > but he has correctly made that distinction. > > Actually, it may be that in some cases a bank closed immediately as soon > as a successful withdrawal request left it with too little funds, so the > number might actually be less that 2294. > There are all kinds of different scenarios possible, leading to all sorts of different numbers for the people caught in exceptional circumstances during bank failure. I think the least likely conceivable possibility is to imagine that the failure of a bank is an instantaneous event that happens in the middle of a single withdrawal. The analogue with software would be a program with thousands of threads running at once, across dozens of cores, on a system that is running many such programs. Each thread will be allocating and deallocating memory asynchronously. The system will have virtual memory, and lots of other IO going on that affects the speed of the VM backing. To imagine that a /single/ normal allocation attempt turns that from a fully working system to a fully failed system is clearly absurd. And the same applies to banks. >> Nor to I see the relevence to checking the return value >> of strdup(3). > > Agreed. Also agreed. Analogies are fine if they shed some light on the topic under discussion. This one started out badly (it seems to have been a suggestion that some bad things only occur very rarely, so you should pretend they won't happen to you), and it got rapidly less realistic and less relevant.