GAttrib: Add debug message for GAttrib references

This commit is contained in:
Claudio Takahasi 2012-02-09 12:41:36 -03:00 committed by Johan Hedberg
parent 9fe2663e2a
commit e05011b3f3
2 changed files with 11 additions and 2 deletions

View File

@ -59,7 +59,7 @@ bin_PROGRAMS += attrib/gatttool
attrib_gatttool_SOURCES = attrib/gatttool.c attrib/att.c attrib/gatt.c \
attrib/gattrib.c btio/btio.c \
attrib/gatttool.h attrib/interactive.c \
attrib/utils.c
attrib/utils.c src/log.c
attrib_gatttool_LDADD = lib/libbluetooth-private.la @GLIB_LIBS@ @READLINE_LIBS@
endif

View File

@ -31,6 +31,7 @@
#include <bluetooth/bluetooth.h>
#include <bluetooth/uuid.h>
#include "log.h"
#include "att.h"
#include "btio.h"
#include "gattrib.h"
@ -147,6 +148,8 @@ GAttrib *g_attrib_ref(GAttrib *attrib)
g_atomic_int_inc(&attrib->refs);
DBG("%p: ref=%d", attrib, attrib->refs);
return attrib;
}
@ -205,10 +208,16 @@ static void attrib_destroy(GAttrib *attrib)
void g_attrib_unref(GAttrib *attrib)
{
gboolean ret;
if (!attrib)
return;
if (g_atomic_int_dec_and_test(&attrib->refs) == FALSE)
ret = g_atomic_int_dec_and_test(&attrib->refs);
DBG("%p: ref=%d", attrib, attrib->refs);
if (ret == FALSE)
return;
attrib_destroy(attrib);