Path: csiph.com!weretis.net!feeder9.news.weretis.net!news.quux.org!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: candycanearter07 Newsgroups: comp.os.linux.misc Subject: Re: Joy of this, Joy of that Date: Fri, 22 Nov 2024 20:40:03 -0000 (UTC) Organization: the-candyden-of-code Lines: 29 Message-ID: References: <6iKdnTQOKNh6AqD6nZ2dnZfqn_idnZ2d@earthlink.com> <20241120081039.00006d2a@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Fri, 22 Nov 2024 21:40:04 +0100 (CET) Injection-Info: dont-email.me; posting-host="738d5fd232904bb7b5d47ff6a07ccbc7"; logging-data="1414396"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/FueU7VWga6R2z5/9nFsjEBG6tqiYV3T8/F9JcXzotiw==" User-Agent: slrn/1.0.3 (Linux) Cancel-Lock: sha1:4yXxZhpTOk3F7T8XFYrGpgWFqx0= X-Face: b{dPmN&%4|lEo,wUO\"KLEOu5N_br(N2Yuc5/qcR5i>9-!^e\.Tw9?/m0}/~:UOM:Zf]% b+ V4R8q|QiU/R8\|G\WpC`-s?=)\fbtNc&=/a3a)r7xbRI]Vl)r<%PTriJ3pGpl_/B6!8pe\btzx `~R! r3.0#lHRE+^Gro0[cjsban'vZ#j7,?I/tHk{s=TFJ:H?~=]`O*~3ZX`qik`b:.gVIc-[$t/e ZrQsWJ >|l^I_[pbsIqwoz.WGA] wrote at 18:53 this Friday (GMT): > On 2024-11-22, The Natural Philosopher wrote: > >> On 22/11/2024 10:45, Richard Kettlewell wrote: >> >>> The one place I’ll use a goto (in C) is to branch to unified cleanup >>> code in an error case, usually using a macro both to emphasize what’s >>> going on and to stop the error-handling guff from dominating what the >>> reader sees. >> >> +1 >> GOTO snafu_nuclear_option... :-) > > All my programs contain a routine called quit_cleanup(); it takes > a single argument, which is either an error message or NULL. > It frees all allocated memory, closes any open files, etc. > (all such variables are global and I initialize them to NULL > or whatever other value is appropriate). Then, if the error > message argument is not NULL, it displays and/or logs the > message and calls exit() with a non-zero argument. If the > error message argument is NULL, it simply calls exit(0). > I can call it from anywhere, and it guarantees an orderly shutdown. Unless you specifically use your own allocation wrapper that adds it to an internal list, how do you deallocate "all" the allocations you've done? -- user is generated from /dev/urandom