Article View: comp.lang.c++
Article #132Re: “The end of software secrecy is almost upon
From: Johann 'Myrkraverk' Oskarsson
Date: Wed, 21 Oct 2026 12:09
Date: Wed, 21 Oct 2026 12:09
54 lines
3943 bytes
3943 bytes
On 10/21/2026 7:18 AM, Charlie Gibbs wrote: > On 2026-10-20, Lawrence D’Oliveiro <ldo@nz.invalid> wrote: > >> On Tue, 20 Oct 2026 19:04:55 GMT, Charlie Gibbs wrote: >> >>> The undisciplined use of GOTOs is bad, agreed. >> >> Is there such a thing as a *disciplined* use of gotos? > > Yes, especially in COBOL or assembly language. For instance, > a GOTO to the end of a function ensures any of its cleanup code > gets executed, and fulfils a goal of structured proramming: > each function has one exit point. > >> I find the C code I write tends to do a lot of dynamic resource >> allocations. These can sometimes fail with errors. So error recovery >> will invariably involve cleaning up those parts of the allocations >> which already succeeded. Gotos are no good for this; you need to exit >> levels of structure nesting one by one, disposing of allocations as >> you go. > > I know that a lot of CS types are going to stick pins into little > dolls that look like me for saying this, but IMHO resource pointers, > handles, etc. should be global. Possible exceptions are resources > that are going to be used solely by the current function - but even > then, if that function calls another function that fails horribly, > there's stuff that might not get cleaned up. That's why all my > C programs contain a function quit_cleanup(char *errmsg), which > de-allocates all resources and then exits (displaying "errmsg" > if it isn't NULL). I can call that function anywhere, safe in > the knowledge that by the time it finishes (it never returns), > everything will have be freed. > Side note: I chose not to comment on any of the other followups by the less experienced coders. I personally have no problem with your app- roach. That works for a single process, but once you start making libraries like Lua that can be loaded and then unloaded the rules change somewhat. SQLite3 can be used similarly. Though I doubt many people load either library dynamically, and then un- load; yet as far as I'm aware, both libraries support such usage. I added comp.lang.misc because I'm not aware of a Lua discussion group. Best wishes, and happy resource cleanup! -- Johann | email: invalid -> com | http://www.myrkraverk.com/blog/ I'm not from the Internet, I just work there. | via Easynews.com https://bsky.app/profile/myrkraverk.bsky.social | for ( ;; ) _:; Federated at https://fed.brid.gy/bsky/myrkraverk.bsky.social
Technical Details
Message-ID:
<cY1CS.317266$UXC8.242759@fx04.ams4>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!peer02.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!fx04.ams4.POSTED!not-for-mailReferences:
<11amvre$15far$1@dont-email.me> <11b5tdb$2cs5l$1@dont-email.me> <11b64cp$end$1@panix2.panix.com> <11b64hj$2faos$1@dont-email.me> <11b679m$6dl$1@panix2.panix.com> <11b6u68$2neta$1@dont-email.me> <11b6v90$2nine$3@dont-email.me> <11b87t8$379mv$1@dont-email.me> <11b8b2k$p44i$1@dont-email.me> <rXOBS.7015$5Iy.3911@fx04.iad> <11b8h83$3b48o$1@dont-email.me> <oFSBS.93666$Q3f.6740@fx05.iad>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!peer02.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!fx04.ams4.POSTED!not-for-mail MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: “The end of software secrecy is almost upon Newsgroups: comp.lang.fortran,comp.lang.c++,alt.comp.lang.rust,alt.folklore.computers,comp.lang.misc References: <11amvre$15far$1@dont-email.me> <11b5tdb$2cs5l$1@dont-email.me> <11b64cp$end$1@panix2.panix.com> <11b64hj$2faos$1@dont-email.me> <11b679m$6dl$1@panix2.panix.com> <11b6u68$2neta$1@dont-email.me> <11b6v90$2nine$3@dont-email.me> <11b87t8$379mv$1@dont-email.me> <11b8b2k$p44i$1@dont-email.me> <rXOBS.7015$5Iy.3911@fx04.iad> <11b8h83$3b48o$1@dont-email.me> <oFSBS.93666$Q3f.6740@fx05.iad> Content-Language: en-US From: Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> Organization: Watcom Pro Ltd. In-Reply-To: <oFSBS.93666$Q3f.6740@fx05.iad> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Lines: 54 Message-ID: <cY1CS.317266$UXC8.242759@fx04.ams4> X-Complaints-To: abuse@easynews.com X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly. Date: Wed, 21 Oct 2026 20:09:42 +0800 X-Received-Bytes: 3799