Sujet : Re: So You Think You Can Const?
De : 643-408-1753 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.lang.cDate : 10. Jan 2025, 19:37:49
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20250110103252.718@kylheku.com>
References : 1 2 3 4
User-Agent : slrn/pre1.0.4-9 (Linux)
On 2025-01-10, Andrey Tarasevich <
andreytarasevich@hotmail.com> wrote:
On 01/09/25 12:12 AM, Julio Di Egidio wrote:
I do not understand that: `free` is changing the pointed data, so how
can `const void *` even be "correct"?
>
`free` is destroying the pointed data.
>
Every object in C object model has to be created (when its lifetime
begins) and has to be eventually destroyed (when its lifetime ends).
That is not so. Literals can be put into a ROM image.
Well, sure, that is created in a factory, and destroyed when recycled.
The point is that the data's lifetime can span over countless
invocations of the program; the program can never observe a time which
is outside of the lifetime of those objects.
So, destruction is not really a "modifying" operation. Destruction of an
Destruction by malloc is modifying in any system that recycles the
memory for another allocation.
-- TXR Programming Language: http://nongnu.org/txrCygnal: Cygwin Native Application Library: http://kylheku.com/cygnalMastodon: @Kazinator@mstdn.ca