Deutsch English Français Italiano |
<vlu6ha$ht1i$2@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: Julio Di Egidio <julio@diegidio.name> Newsgroups: comp.lang.c Subject: Re: So You Think You Can Const? Date: Sat, 11 Jan 2025 17:33:46 +0100 Organization: A noiseless patient Spider Lines: 37 Message-ID: <vlu6ha$ht1i$2@dont-email.me> References: <vljvh3$27msl$1@dont-email.me> <vlma9m$2s5e5$1@dont-email.me> <vlolsf$3cnll$4@dont-email.me> <vlqd9p$3s4ai$2@dont-email.me> <vlqstb$3uk5j$1@dont-email.me> <87v7umpkfv.fsf@nosuchdomain.example.com> <vltjqc$j8n0$1@dont-email.me> <vlu508$ht1i$1@dont-email.me> <vlu5q6$ht1h$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Sat, 11 Jan 2025 17:33:46 +0100 (CET) Injection-Info: dont-email.me; posting-host="7e037d26dd5ee7b007fdefa6fea137e2"; logging-data="586802"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+GeKHU4xEyQ5YfHoKl1hkl9X3nVOb+V/c=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:lYNhfmTa+oZlkDEdBRznJTltDJ0= In-Reply-To: <vlu5q6$ht1h$1@dont-email.me> Content-Language: en-GB Bytes: 3007 On 11/01/2025 17:21, Julio Di Egidio wrote: > On 11/01/2025 17:07, Julio Di Egidio wrote: >> 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? > > In fact, along that line, I could see one might insist that "strictly > speaking, it should be `void free(void *const p)` because the pointer > value is not changed" (my considerations above are indeed more > "semantic"), OTOH, I just cannot see a case for `void free(void const > *p)`, not even strictly technically. P.S. Sorry, I might have snipped too much: to be clear, David Brown is actually referring to a `void free(void ** p)` in his statement above, so his "changing the pointer" is to be read in that context: I am back to the question of is there a problem with the standard signature of `free`. -Julio