summaryrefslogtreecommitdiffstats
path: root/src/device.c
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2008-09-11 15:37:57 -0300
committerLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2008-09-11 15:37:57 -0300
commite62d9fec6ad663d335a8f915568e5f35cd0633b1 (patch)
tree600a6a66f05e950efeb48ba2a8abffe4520ef5a1 /src/device.c
parent9593b3b600a60d2859cdc7c41ab700f57c915d2d (diff)
Fix memory allocation of drivers uuid list to be dinamic as drivers may be unregistered.
Diffstat (limited to 'src/device.c')
-rw-r--r--src/device.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/device.c b/src/device.c
index 5348c296..84767823 100644
--- a/src/device.c
+++ b/src/device.c
@@ -832,8 +832,12 @@ static void update_services(struct browse_req *req, sdp_list_t *recs)
/* Driver uuid found */
l = g_slist_find_custom(req->uuids, uuid_str,
(GCompareFunc) strcasecmp);
- if (l)
- req->uuids = g_slist_remove(req->uuids, l->data);
+ if (l) {
+ char *uuid = l->data;
+
+ req->uuids = g_slist_remove(req->uuids, uuid);
+ g_free(uuid);
+ }
/* Check for duplicates */
if (sdp_list_find(req->records, rec, rec_cmp))
@@ -903,7 +907,7 @@ static void search_cb(sdp_list_t *recs, int err, gpointer user_data)
update_services(req, recs);
if (!req->uuids_added && !req->uuids_removed) {
- debug("%s: No service found", device->path);
+ debug("%s: No service update", device->path);
goto proceed;
}
@@ -991,8 +995,11 @@ static void browse_cb(sdp_list_t *recs, int err, gpointer user_data)
/* Search for drivers uuids */
if (req->uuids) {
- bt_string2uuid(&uuid, req->uuids->data);
- req->uuids = g_slist_remove(req->uuids, req->uuids->data);
+ char *uuid_str = req->uuids->data;
+
+ bt_string2uuid(&uuid, uuid_str);
+ req->uuids = g_slist_remove(req->uuids, uuid_str);
+ g_free(uuid_str);
bt_search_service(&src, &dst, &uuid, browse_cb, user_data, NULL);
return;
}
@@ -1017,11 +1024,14 @@ static void init_browse(struct browse_req *req)
int i;
for (i = 0; driver->uuids[i]; i++) {
+ char *uuid;
+
if (g_slist_find_custom(req->uuids, driver->uuids[i],
(GCompareFunc) strcasecmp))
return;
- req->uuids = g_slist_append(req->uuids,
- driver->uuids[i]);
+
+ uuid = g_strdup(driver->uuids[i]);
+ req->uuids = g_slist_append(req->uuids, uuid);
}
}