Re: freeing text

Eric Lemings <eric b lemings lmco com> writes:
Havoc Pennington wrote:

I usually mention it either way, and also we have G_CONST_RETURN now
which will indicate whether you need to free, at least for return
values (though not for out params such as this one).

The only thing that a const return value should convey is you can't change
the value.  I don't see why anybody would think you have to free the value
because it's const.

The point is that you never have to free a const value (free is a
specific instance of changing the value). 

Also, conveniently, I don't think we have any APIs that return a
non-const string by reference. i.e. we don't have APIs where you get a
string by reference and are allowed to modify it. 

Thus the const is a reliable indicator of whether to free, for GTK.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]