Re: [PATCH BlueZ 1/6] Proximity Monitor: Write Alert Level to Reporter

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

 



Hi Claudio,

On Thu, Jul 28, 2011, Claudio Takahasi wrote:
> On Thu, Jul 28, 2011 at 1:36 AM, Santiago Carot <sancane@xxxxxxxxx> wrote:
> >> --- a/proximity/monitor.c
> >> +++ b/proximity/monitor.c
> >> @@ -35,19 +35,28 @@
> >>  #include <sys/stat.h>
> <snip>
> >> +static void attio_connected_cb(GAttrib *attrib, gpointer user_data)
> >> +{
> >> +       struct monitor *monitor = user_data;
> >> +
> >> +       monitor->attrib = attrib;
> >
> > GAttrib is a referenciable structure. Don't you increment the
> > reference counter if you are storing an internal reference in monitor?
> 
> References are controlled by the core. The last reference for the
> GAttrib will not be release by the core until the last connection
> callback is unregistered. This is the reason why reference control
> inside the profiles are not needed. If it is more clear to everybody
> we can add reference counting in the profiles, but it will be a
> duplicated logic. Every btd_device_remove_attio_callback call will be
> followed by g_attrib_unref.

The general rule should be that you never copy a reference counted
pointer without the use of ref(). So in this case I do think it'd be
better to ref() when you copy (from attrib to monitor->attrib) and
unref() before you set to NULL.

Johan
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux