Thread (3 messages) flat view 3 messages, 2 authors, 2011-07-28

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

From: Johan Hedberg <hidden>
Date: 2011-07-28 13:12:35

Possibly related (same subject, not in this thread)

Hi Claudio,

On Thu, Jul 28, 2011, Claudio Takahasi wrote:
On Thu, Jul 28, 2011 at 1:36 AM, Santiago Carot [off-list ref] wrote:
quoted
quoted
--- a/proximity/monitor.c
+++ b/proximity/monitor.c
@@ -35,19 +35,28 @@
 #include <sys/stat.h>
<snip>
quoted
quoted
+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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help