Liste des Groupes | Revenir à cl c |
On 2025-01-09, Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>Julio Di Egidio <julio@diegidio.name> writes:>
>On 08/01/2025 17:48, Andrey Tarasevich wrote:>
[...]
>>It is perfectly safe. One can even argue that standard declaration>
if `free` as `void free(void *)` is defective. It should have been
`void free(const void *)` from the very beginning.
I do not understand that: `free` is changing the pointed data, so
how can `const void *` even be "correct"?
No, `free` doesn't (necessarily) change the pointed-to data.
Any attempt to access the allocated data after free() has undefined
behavior, so it might be modified, but all free() needs to do is
make it available for further allocation. It might do so without
touching the data itself.
It doesn't matter because if free were to change the pointed-to
data, that would be only wrong if the effective type were const.
[...]
Les messages affichés proviennent d'usenet.