Liste des Groupes | Revenir à cl c |
On 01/07/25 11:32 AM, Julio Di Egidio wrote:<snip>
I do not understand that: `free` is changing the pointed data, so how can `const void *` even be "correct"?E.g. consider this little internal helper of mineIt 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.
(which implements an interface that is public to
do an internal thing...), where I am casting to
pointer to non-constant data in order to free the
pointed data (i.e. without warning):
>
```c
static int MyStruct_free_(MyStruct_t const *pT) {
assert(pT);
>
free((MyStruct_t *)pT);
>
return 0;
}
```
>
Assuming, as said, that the data was originally
allocated with malloc, is that code safe or
something can go wrong even in that case?
Les messages affichés proviennent d'usenet.