aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--attrib/gattrib.c18
-rw-r--r--attrib/gattrib.h3
2 files changed, 21 insertions, 0 deletions
diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index 405bd741..bcab5cc0 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -44,7 +44,9 @@ struct _GAttrib {
GSList *events;
guint next_cmd_id;
guint next_evt_id;
+ GDestroyNotify destroy;
GAttribDisconnectFunc disconnect;
+ gpointer destroy_user_data;
gpointer disc_user_data;
};
@@ -188,6 +190,10 @@ void g_attrib_unref(GAttrib *attrib)
g_source_remove(attrib->read_watch);
g_io_channel_unref(attrib->io);
+
+ if (attrib->destroy)
+ attrib->destroy(attrib->destroy_user_data);
+
g_free(attrib);
}
@@ -203,6 +209,18 @@ gboolean g_attrib_set_disconnect_function(GAttrib *attrib,
return TRUE;
}
+gboolean g_attrib_set_destroy_function(GAttrib *attrib,
+ GDestroyNotify destroy, gpointer user_data)
+{
+ if (attrib == NULL)
+ return FALSE;
+
+ attrib->destroy = destroy;
+ attrib->destroy_user_data = user_data;
+
+ return TRUE;
+}
+
static void destroy_receiver(gpointer data)
{
struct _GAttrib *attrib = data;
diff --git a/attrib/gattrib.h b/attrib/gattrib.h
index 011b9da3..4306ca4e 100644
--- a/attrib/gattrib.h
+++ b/attrib/gattrib.h
@@ -47,6 +47,9 @@ void g_attrib_unref(GAttrib *attrib);
gboolean g_attrib_set_disconnect_function(GAttrib *attrib,
GAttribDisconnectFunc disconnect, gpointer user_data);
+gboolean g_attrib_set_destroy_function(GAttrib *attrib,
+ GDestroyNotify destroy, gpointer user_data);
+
guint g_attrib_send(GAttrib *attrib, guint8 opcode, const guint8 *pdu,
guint16 len, GAttribResultFunc func,
gpointer user_data, GDestroyNotify notify);