[Info-vax] BASIC (and Horizon)

Stephen Hoffman seaohveh at hoffmanlabs.invalid
Fri Feb 2 16:43:15 EST 2024


On 2024-01-31 21:22:33 +0000, Lawrence D'Oliveiro said:

> On Wed, 31 Jan 2024 11:05:22 -0500, Stephen Hoffman wrote:
> 
>> (Not that I prefer to have to implement manual cleanup, much as I'd 
>> like to avoid explicitly deallocating memory in C.
> 
> Note that free(3) is defined as idempotent; freeing a NULL pointer is a 
> harmless no-op. That simplifies things a lot.

Pragmatically, the difference between (pseudo-code) free(xyz) where xyz 
is nulllptr or ((void*)0) or whatever, and the same brute-force if 
(xyz) free(xyz); code, or a macro of same, is negligible.

No, that free ignores a null doesn't simplify the bookkeeping. There 
are other languages that are easier here.

Though semi-similarly, sending a null at a method in Objective C can be 
useful. And can be a source of confusion and bugs.

On OpenVMS, using VM zones reduces the memory management bookkeeping in 
some contexts, as the whole zone can be freed in one shot. This 
technique can be handy for command parsers, where you know you're done 
with ~everything parsing-related when you're parsing the next command.

There are other trade-offs that can make this effort easier, not the 
least of which is garbage collection.

Apropos of nothing, asctime() and ctime() are now (C23) deprecated.

And some semi-related reading: https://jorengarenar.github.io/blog/less-known-c


-- 
Pure Personal Opinion | HoffmanLabs LLC 




More information about the Info-vax mailing list