Path: csiph.com!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: So You Think You Can Const? Date: Fri, 10 Jan 2025 10:56:04 -0800 Organization: None to speak of Lines: 21 Message-ID: <87v7umpkfv.fsf@nosuchdomain.example.com> References: MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Fri, 10 Jan 2025 19:56:04 +0100 (CET) Injection-Info: dont-email.me; posting-host="e16be66d43b38b7ea574a81744fe375a"; logging-data="204683"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19gkF4i7AR2MVwM8uWuMQLA" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:Lk0NHNnno1ZIu6LSFqAvpId+gjI= sha1:Ukbgy8xVMtf/s9zakgLHGXUdQ1E= Xref: csiph.com comp.lang.c:389968 David Brown writes: [...] > If you want a better signature for "free", then I would suggest "void > free(void ** p)" - that (to me) more naturally shows that the function > is freeing the pointer, while also greatly reducing the "use after > free" errors in C code by turning them into "dereferencing a null > pointer" errors which are more easily caught by many OS's. I'm not sure that would work. A void** argument means you need to pass a pointer to a void* object. If you've assigned the converted result of malloc() to, say, an int* object, you don't have a void* object. (int* and void* might not even have the same representation). Some kind of generic function that takes a pointer to an object of any object pointer type could work, but the language doesn't support that. (C++ addressed this by making `new` and `delete` built-in operators rather than library functions.) -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com void Void(void) { Void(); } /* The recursive call of the void */