Sujet : Re: So You Think You Can Const?
De : julio (at) *nospam* diegidio.name (Julio Di Egidio)
Groupes : comp.lang.cDate : 11. Jan 2025, 17:07:36
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vlu508$ht1i$1@dont-email.me>
References : 1 2 3 4 5 6 7
User-Agent : Mozilla Thunderbird
On 11/01/2025 12:14, David Brown wrote:
On 10/01/2025 19:56, Keith Thompson wrote:
<snip>
The idea was to place the emphasis on "free" changing the pointer, rather than the data pointed to.
I feel I am still altogether missing the point.
Is my understanding correct that when freeing a pointer: 1) the pointer value, i.e. the address it holds, does not change; OTOH, 2) the pointed-to object does change, in the sense that it is marked unusable (and, supposedly, made available to re-allocation)?
Moreover, while the pointer value has not changed, it is in fact changed in the sense that it has become invalid, namely the pointer cannot be used (validly dereferenced) anymore. Not just that, but *every* pointer to the same object, i.e. holding the same address, has become invalid.
All that considered, how isn't `void free(void *p)`, i.e. with no const qualifiers anywhere, the only reasonable signature?
-Julio