On Fri, Jan 18, 2008 at 08:53:44AM -0500, Andy Lutomirski wrote:That's only if neither function has side effects noticeable by the other. Invalidating the pointer in (k)free is rather noticeable. Most of the time, const pointer arguments means "I won't change the contents of the object so that you'll notice by reading it in a normal way afterwards". That's pretty much what mutable in a variety of languages (including C++) is about, saying "this field is internal management stuff not visible from the external interface, so I need to be able to change it even through const pointers I got as parameters". Reference counters for copy-on-write setups is the usual example of use. In the case of deallocation functions you are not allowed to do anything through the pointer or its aliases after the function returns. So we're outside of the "most of the time" case, since you're not allowed to try to notice any change. Pragmatism takes over, you want the type that catches as many possible types as possible while staying reasonable (volatile is never reasonable), and that's const void *. As simple as that. As for releasing resources through const pointers, that happens all the time as soon as your const use is tight, and if you think forcing the systematic addition of a (void *) cast is going to make your code more readable, well, you need more experience in maintaining other people's applications. delete in C++ allows const pointers. Think about it. OG. --
| Theodore Tso | Re: -mm merge plans for 2.6.23 -- sys_fallocate |
| Amit K. Arora | [RFC] Heads up on sys_fallocate() |
| Tarkan Erimer | Re: Dual-Licensing Linux Kernel with GPL V2 and GPL V3 |
| Greg Kroah-Hartman | [PATCH 011/196] sysfs: Fix a copy-n-paste typo in comment |
git: | |
| Jarek Poplawski | Re: [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
| David Miller | Re: [GIT]: Networking |
| Gerrit Renker | [PATCH 27/37] dccp: Integration of dynamic feature activation - part 2 (server side) |
| Frans Pop | svc: failed to register lockdv1 RPC service (errno 97). |
