Adam Jackson <[email protected]> writes:

> I'm not totally happy with this.  Casting away const on the argument to
> free() potentially hides bugs, because the point is you _shouldn't_ be
> able to free() things in .rodata, ie, actually constant values.

Agreed. The issue is that different parts of the X server use either
const values or allocated values and store those in the same structure
members. Each part "knows" what it has done; const values are "never"
freed, while allocated values "always" are.

So, we have three choices:

 1) Stick casts where constant strings are assigned to non-const
    members

 2) Copy constant strings, and then figure out where to free them
    reliably

 3) Stick casts where non-constant strings are freed from const
    members.

2) is the 'most correct', and would eliminate all casts, but is also
both the least efficient (meh, not a huge deal, but still), *and* the
most bug-prone within the existing code as it requires that we go and
find a suitable place to free the newly allocated storage.

Which is why I really only considered 1) and 3), and picked 3) because
it required fewer casts, and then only in calls to 'free', which might
make it slightly easier to audit.

-- 
[email protected]

Attachment: pgpsS28W9JVzf.pgp
Description: PGP signature

_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to