[PATCH 00/37] Warning fixes (post 1.15 proposed changes)
Mouse
mouse at Rodents-Montreal.ORG
Mon Nov 18 09:03:40 PST 2013
> What I suggested was to fix it properly by not using const for
> pointers to dynamically allocated memory which is meant to be freed
> at some point. [...]
One tack I've taken in some of my own code is to have two pointers, a
const one to the data to use and a non-const one to the data to free.
Then, when setting the data pointer, set the to-free pointer to either
the same thing or to nil, depending on whether the data needs freeing.
Then, of course, when it comes time to free anything that should be
freed, just free the to-free pointer.
I find proper const poisoning is easily worth the price. In something
as big as X, the conversion would admittedly be a big job, but I would
most definitely recommend doing it (though I realize that is armchair
quarterbacking).
I think the only thing I use a qualifier-stripper for is writev().
/~\ The ASCII Mouse
\ / Ribbon Campaign
X Against HTML mouse at rodents-montreal.org
/ \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B
More information about the xorg-devel
mailing list