const, the errors framework, and -Wcast-qual
hartmans at MIT.EDU
Tue Nov 3 11:22:24 EST 2009
I agree that for non-refcounted objects that freeing a const pointer
In the case of objects with refcounts where you may want to ask some
people not to mutate the object, I think freeing through a const
pointer when the last reference goes away is better than vere using
const pointers for such aliases. That situation does not come up in our code base.
I also think that const pointers are justified when they sometimes
point to shared storage (like error strings) that it would be highly
undesirable to change even if that meant freeing through a const
What I think I'm saying is that Anders/your rule of don't free through
const is probably too strong as a rule,but is a good guidline. I
agree with you that applying that guideline in the cases you're
thinking of would improve the code.
More information about the krbdev