Re: 2.x API and GDateTime



On Sun, 2012-12-16 at 15:25 +0100, Roland Peffer wrote:
> Thanks for the answer.
> I checked again:
> 
>  grl_media_set_creation_date (media);  increases the reference counter.
> 
>  grl_media_get_creation_date(media)  leaves reference counter untouched.
> 
> 
> For my understanding this is not correct.
> Either grl_media_get_creation_date should be marked with const ,


Probably it would make sense.

But to avoid changing the API in this moment, I will fix the
documentation so it makes clearly that returned value shouldn't be
modified at all.

> or better also should increase the ref counter on the GDateTime object.

This option would make this function behave different than the other
grl_media_get_foo() functions.

In these functions the returned type is sort of "const". The returned
data is just to be used as read-only mode, and shouldn't it be freed.

So you have

foo = grl_media_get_foo(m)

And you can forget about freeing foo to avoid leaks.

And we want the same for datetime.

dt = grl_media_get_creation_date(m)

And you can forget also about freeing dt to avoid leaks.

Increasing the references makes compulsory to run g_date_time_unref()
always on your side to avoid leaks. So you are adding a different
behaviour.




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