[PATCH 00/37] Warning fixes (post 1.15 proposed changes)

Keith Packard keithp at keithp.com
Mon Nov 18 09:21:09 PST 2013


"Jasper St. Pierre" <jstpierre at mecheye.net> writes:

> The warnings are trying to prevent you from freeing a string constant and
> having corrupt memory or double frees or worse. Casts are a *very* bad way
> to work around the issue, and I'd highly recommend that if you want to
> potentially free something, you use `char *`, not `const char *`.

In a new project, that would be lovely. In this case, we're often
storing string constants *or* allocated memory in the same struct
member, and the decision to free is generally based on external
knowledge of whether the storage was allocated or not.

So, there's going to be a cast somewhere, I just prefer the cast to be
in the call to free rather than the assignment of the constant string.

-- 
keith.packard at intel.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 827 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg-devel/attachments/20131118/dda51e7d/attachment.pgp>


More information about the xorg-devel mailing list